diff options
author | Armen Kesablyan | 2012-05-08 16:43:43 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-05-08 16:43:43 -0700 |
commit | dc075ffcc6dd03c090d90fad999eee9b924d56ee (patch) | |
tree | 867f8bdd588c8f9076979233ca46a688ff70523e /imports/codemirror/mode/xquery/test/testNamespaces.js | |
parent | 5d7e470351fd150d5e70a97332fa2f2553797499 (diff) | |
parent | 4d949f141247215b5f2a6ec0cfc7d2d31cf2bb1f (diff) | |
download | ninja-dc075ffcc6dd03c090d90fad999eee9b924d56ee.tar.gz |
Merge branch 'refs/heads/dom-architecture' into binding
Conflicts:
js/components/layout/tools-properties.reel/tools-properties.html
Signed-off-by: Armen Kesablyan <armen@motorola.com>
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 | |||