Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
1467f746
Commit
1467f746
authored
Nov 25, 2014
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add XML unit tests.
parent
5aed33b6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
2 deletions
+71
-2
tests/jsunit/blockly_test.js
tests/jsunit/blockly_test.js
+0
-0
tests/jsunit/generator_test.js
tests/jsunit/generator_test.js
+0
-0
tests/jsunit/index.html
tests/jsunit/index.html
+2
-2
tests/jsunit/names_test.js
tests/jsunit/names_test.js
+0
-0
tests/jsunit/xml_test.js
tests/jsunit/xml_test.js
+69
-0
No files found.
tests/blockly_test.js
→
tests/
jsunit/
blockly_test.js
View file @
1467f746
File moved
tests/generator_test.js
→
tests/
jsunit/
generator_test.js
View file @
1467f746
File moved
tests/
blockly_test
.html
→
tests/
jsunit/index
.html
View file @
1467f746
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<title>
Unit Tests for Blockly
</title>
<title>
Unit Tests for Blockly
</title>
<script
type=
"text/javascript"
src=
"../../
closure-library/closure/goog/base
.js"
></script>
<script
type=
"text/javascript"
src=
"../../
blockly_uncompressed
.js"
></script>
<script
type=
"text/javascript"
>
goog
.
require
(
'
goog.testing.jsunit
'
);
</script>
<script
type=
"text/javascript"
>
goog
.
require
(
'
goog.testing.jsunit
'
);
</script>
<script
type=
"text/javascript"
src=
"../blockly_uncompressed.js"
></script>
</head>
</head>
<body>
<body>
<script
type=
"text/javascript"
src=
"blockly_test.js"
></script>
<script
type=
"text/javascript"
src=
"blockly_test.js"
></script>
<script
type=
"text/javascript"
src=
"generator_test.js"
></script>
<script
type=
"text/javascript"
src=
"generator_test.js"
></script>
<script
type=
"text/javascript"
src=
"names_test.js"
></script>
<script
type=
"text/javascript"
src=
"names_test.js"
></script>
<script
type=
"text/javascript"
src=
"xml_test.js"
></script>
</body>
</body>
</html>
</html>
tests/names_test.js
→
tests/
jsunit/
names_test.js
View file @
1467f746
File moved
tests/jsunit/xml_test.js
0 → 100644
View file @
1467f746
/**
* Blockly Tests
*
* Copyright 2014 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'
use strict
'
;
var
XML_TEXT
=
[
'
<xml xmlns="http://www.w3.org/1999/xhtml">
'
,
'
<block type="controls_repeat_ext" id="10" inline="true" x="21" y="23">
'
,
'
<value name="TIMES">
'
,
'
<block type="math_number" id="11">
'
,
'
<field name="NUM">10</field>
'
,
'
</block>
'
,
'
</value>
'
,
'
<statement name="DO">
'
,
'
<block type="variables_set" id="139" inline="true">
'
,
'
<field name="VAR">item</field>
'
,
'
<value name="VALUE">
'
,
'
<block type="lists_create_empty" id="171"></block>
'
,
'
</value>
'
,
'
<next>
'
,
'
<block type="text_print" id="78" inline="false">
'
,
'
<value name="TEXT">
'
,
'
<block type="text" id="189">
'
,
'
<field name="TEXT">Hello</field>
'
,
'
</block>
'
,
'
</value>
'
,
'
</block>
'
,
'
</next>
'
,
'
</block>
'
,
'
</statement>
'
,
'
</block>
'
,
'
</xml>
'
].
join
(
'
/n
'
);
function
test_textToDom
()
{
var
dom
=
Blockly
.
Xml
.
textToDom
(
XML_TEXT
);
assertEquals
(
'
XML tag
'
,
'
xml
'
,
dom
.
nodeName
);
assertEquals
(
'
Block tags
'
,
6
,
dom
.
getElementsByTagName
(
'
block
'
).
length
);
}
function
test_domToText
()
{
var
dom
=
Blockly
.
Xml
.
textToDom
(
XML_TEXT
);
var
text
=
Blockly
.
Xml
.
domToText
(
dom
);
assertEquals
(
'
Round trip
'
,
XML_TEXT
.
replace
(
/
\s
+/g
,
''
),
text
.
replace
(
/
\s
+/g
,
''
));
}
function
test_domToPrettyText
()
{
var
dom
=
Blockly
.
Xml
.
textToDom
(
XML_TEXT
);
var
text
=
Blockly
.
Xml
.
domToPrettyText
(
dom
);
assertEquals
(
'
Round trip
'
,
XML_TEXT
.
replace
(
/
\s
+/g
,
''
),
text
.
replace
(
/
\s
+/g
,
''
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment