aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/xquery/test/testNamespaces.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-05-07 16:30:19 -0700
committerJohn Mayhew2012-05-07 16:30:19 -0700
commitdb4ba95f50148198759dde503ec1c778184d9dbe (patch)
tree8b79ad58108af2f17d15abc8cdc33d35229ab20d /imports/codemirror/mode/xquery/test/testNamespaces.js
parent843d8ea8ee58a54bcb71d7b28dbf78fae153b491 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-db4ba95f50148198759dde503ec1c778184d9dbe.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/components/layout/tools-list.reel/tools-list.html js/components/layout/tools-properties.reel/tools-properties.html js/components/tools-properties/brush-properties.reel/brush-properties.html js/components/tools-properties/fill-properties.reel/fill-properties.html js/components/tools-properties/pen-properties.reel/pen-properties.html js/components/tools-properties/pencil-properties.reel/pencil-properties.html js/components/tools-properties/selection-properties.reel/selection-properties.html js/components/tools-properties/shape-properties.reel/shape-properties.html js/components/tools-properties/tag-properties.reel/tag-properties.html js/components/tools-properties/text-properties.reel/text-properties.html
Diffstat (limited to 'imports/codemirror/mode/xquery/test/testNamespaces.js')
-rw-r--r--imports/codemirror/mode/xquery/test/testNamespaces.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/imports/codemirror/mode/xquery/test/testNamespaces.js b/imports/codemirror/mode/xquery/test/testNamespaces.js
new file mode 100644
index 00000000..4efea63e
--- /dev/null
+++ b/imports/codemirror/mode/xquery/test/testNamespaces.js
@@ -0,0 +1,91 @@
1$(document).ready(function(){
2 module("test namespaces");
3
4// --------------------------------------------------------------------------------
5// this test is based on this:
6//http://mbrevoort.github.com/CodeMirror2/#!exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-10.xq
7// --------------------------------------------------------------------------------
8 test("test namespaced variable", function() {
9 expect(1);
10
11 var input = 'declare namespace e = "http://example.com/ANamespace";\
12declare variable $e:exampleComThisVarIsNotRecognized as element(*) external;';
13
14 var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">namespace</span> <span class="cm-word">e</span> <span class="cm-keyword">=</span> <span class="cm-string">"http://example.com/ANamespace"</span><span class="cm-word">;declare</span> <span class="cm-keyword">variable</span> <span class="cm-variable">$e:exampleComThisVarIsNotRecognized</span> <span class="cm-keyword">as</span> <span class="cm-keyword">element</span>(<span class="cm-keyword">*</span>) <span class="cm-word">external;</span>';
15
16 $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
17 var editor = CodeMirror.fromTextArea($("#editor")[0]);
18 var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
19
20 equal(result, expected);
21 $("#editor").html("");
22 });
23
24
25// --------------------------------------------------------------------------------
26// this test is based on:
27// http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-002.xq
28// --------------------------------------------------------------------------------
29 test("test EQName variable", function() {
30 expect(1);
31
32 var input = 'declare variable $"http://www.example.com/ns/my":var := 12;\
33<out>{$"http://www.example.com/ns/my":var}</out>';
34
35 var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">variable</span> <span class="cm-variable">$"http://www.example.com/ns/my":var</span> <span class="cm-keyword">:=</span> <span class="cm-atom">12</span><span class="cm-word">;</span><span class="cm-tag">&lt;out&gt;</span>{<span class="cm-variable">$"http://www.example.com/ns/my":var</span>}<span class="cm-tag">&lt;/out&gt;</span>';
36
37 $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
38 var editor = CodeMirror.fromTextArea($("#editor")[0]);
39 var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
40
41 equal(result, expected);
42 $("#editor").html("");
43 });
44
45// --------------------------------------------------------------------------------
46// this test is based on:
47// http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-003.xq
48// --------------------------------------------------------------------------------
49 test("test EQName function", function() {
50 expect(1);
51
52 var input = 'declare function "http://www.example.com/ns/my":fn ($a as xs:integer) as xs:integer {\
53 $a + 2\
54};\
55<out>{"http://www.example.com/ns/my":fn(12)}</out>';
56
57 var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">"http://www.example.com/ns/my":fn</span> (<span class="cm-variable">$a</span> <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span>) <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span> { <span class="cm-variable">$a</span> <span class="cm-keyword">+</span> <span class="cm-atom">2</span>}<span class="cm-word">;</span><span class="cm-tag">&lt;out&gt;</span>{<span class="cm-variable cm-def">"http://www.example.com/ns/my":fn</span>(<span class="cm-atom">12</span>)}<span class="cm-tag">&lt;/out&gt;</span>';
58
59 $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
60 var editor = CodeMirror.fromTextArea($("#editor")[0]);
61 var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
62
63 equal(result, expected);
64 $("#editor").html("");
65 });
66
67// --------------------------------------------------------------------------------
68// this test is based on:
69// http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-003.xq
70// --------------------------------------------------------------------------------
71 test("test EQName function with single quotes", function() {
72 expect(1);
73
74 var input = 'declare function \'http://www.example.com/ns/my\':fn ($a as xs:integer) as xs:integer {\
75 $a + 2\
76};\
77<out>{\'http://www.example.com/ns/my\':fn(12)}</out>';
78
79 var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">\'http://www.example.com/ns/my\':fn</span> (<span class="cm-variable">$a</span> <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span>) <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span> { <span class="cm-variable">$a</span> <span class="cm-keyword">+</span> <span class="cm-atom">2</span>}<span class="cm-word">;</span><span class="cm-tag">&lt;out&gt;</span>{<span class="cm-variable cm-def">\'http://www.example.com/ns/my\':fn</span>(<span class="cm-atom">12</span>)}<span class="cm-tag">&lt;/out&gt;</span>';
80
81 $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
82 var editor = CodeMirror.fromTextArea($("#editor")[0]);
83 var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
84
85 equal(result, expected);
86 $("#editor").html("");
87 });
88
89});
90
91