diff options
author | Jon Reid | 2012-05-04 14:56:24 -0700 |
---|---|---|
committer | Jon Reid | 2012-05-04 14:56:24 -0700 |
commit | a6dd2917edcfeca1be7553e03281ddd538422ae1 (patch) | |
tree | e6846626bf1e967e80bcd652f6a76bb97abb1789 /imports/codemirror/mode/xquery/test/testNamespaces.js | |
parent | 7fc185cc08b2ba912dbc7bce96f6a465c1dd6dbf (diff) | |
parent | 8964e070fa760d23c2de272ca36b8d9beba6007d (diff) | |
download | ninja-a6dd2917edcfeca1be7553e03281ddd538422ae1.tar.gz |
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'imports/codemirror/mode/xquery/test/testNamespaces.js')
-rw-r--r-- | imports/codemirror/mode/xquery/test/testNamespaces.js | 91 |
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";\ | ||
12 | declare 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"><out></span>{<span class="cm-variable">$"http://www.example.com/ns/my":var</span>}<span class="cm-tag"></out></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"><out></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"></out></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"><out></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"></out></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 | |||