diff options
author | Nivesh Rajbhandari | 2012-05-03 17:09:07 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-05-03 17:09:07 -0700 |
commit | 8be6e94b57f4bd6e28754a6113b4d6a401365e13 (patch) | |
tree | 19f48f969ab872b9ef46cc4e7d6c2b9d2544cd4d /imports/codemirror/mode/xquery/test/testNamespaces.js | |
parent | c14b8d9fd1acde98ffc427b0bbdba7d1442c39a4 (diff) | |
parent | fec9ccee11ea21ffc95edce6e89d0d302b63e3d8 (diff) | |
download | ninja-8be6e94b57f4bd6e28754a6113b4d6a401365e13.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
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 | |||