aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/xquery/test/testBase.js
diff options
context:
space:
mode:
Diffstat (limited to 'imports/codemirror/mode/xquery/test/testBase.js')
-rw-r--r--imports/codemirror/mode/xquery/test/testBase.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/imports/codemirror/mode/xquery/test/testBase.js b/imports/codemirror/mode/xquery/test/testBase.js
new file mode 100644
index 00000000..d40e9eea
--- /dev/null
+++ b/imports/codemirror/mode/xquery/test/testBase.js
@@ -0,0 +1,42 @@
1 $(document).ready(function(){
2 module("testBase");
3 test("eviltest", function() {
4 expect(1);
5
6 var input = 'xquery version "1.0-ml";\
7 (: this is\
8 : a \
9 "comment" :)\
10 let $let := <x attr="value">"test"<func>function() $var {function()} {$var}</func></x>\
11 let $joe:=1\
12 return element element {\
13 attribute attribute { 1 },\
14 element test { 'a' }, \
15 attribute foo { "bar" },\
16 fn:doc()[ foo/@bar eq $let ],\
17 //x } \
18 \
19 (: a more \'evil\' test :)\
20 (: Modified Blakeley example (: with nested comment :) ... :)\
21 declare private function local:declare() {()};\
22 declare private function local:private() {()};\
23 declare private function local:function() {()};\
24 declare private function local:local() {()};\
25 let $let := <let>let $let := "let"</let>\
26 return element element {\
27 attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },\
28 attribute fn:doc { "bar" castable as xs:string },\
29 element text { text { "text" } },\
30 fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],\
31 //fn:doc\
32 }';
33 var expected = '<span class="cm-keyword">xquery</span> <span class="cm-keyword">version</span> <span class="cm-string">"1.0-ml"</span><span class="cm-variable cm-def">;</span> <span class="cm-comment">(: this is : a "comment" :)</span> <span class="cm-keyword">let</span> <span class="cm-variable">$let</span> <span class="cm-keyword">:=</span> <span class="cm-tag">&lt;x </span><span class="cm-attribute">attr</span>=<span class="cm-string">"value"</span><span class="cm-tag">&gt;</span><span class="cm-word">"test"</span><span class="cm-tag">&lt;func&gt;</span><span class="cm-word">function()</span> <span class="cm-word">$var</span> {<span class="cm-keyword">function</span>()} {<span class="cm-variable">$var</span>}<span class="cm-tag">&lt;/func&gt;&lt;/x&gt;</span> <span class="cm-keyword">let</span> <span class="cm-variable">$joe</span><span class="cm-keyword">:=</span><span class="cm-atom">1</span> <span class="cm-keyword">return</span> <span class="cm-keyword">element</span> <span class="cm-word">element</span> { <span class="cm-keyword">attribute</span> <span class="cm-word">attribute</span> { <span class="cm-atom">1</span> }, <span class="cm-keyword">element</span> <span class="cm-word">test</span> { <span class="cm-string">\'a\'</span> }, <span class="cm-keyword">attribute</span> <span class="cm-word">foo</span> { <span class="cm-string">"bar"</span> }, <span class="cm-variable cm-def">fn:doc</span>()[ <span class="cm-word">foo</span><span class="cm-keyword">/</span><span class="cm-word">@bar</span> <span class="cm-keyword">eq</span> <span class="cm-variable">$let</span> ], <span class="cm-keyword">//</span><span class="cm-word">x</span> } <span class="cm-comment">(: a more \'evil\' test :)</span> <span class="cm-comment">(: Modified Blakeley example (: with nested comment :) ... :)</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:declare</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:private</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:function</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:local</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">let</span> <span class="cm-variable">$let</span> <span class="cm-keyword">:=</span> <span class="cm-tag">&lt;let&gt;</span><span class="cm-word">let</span> <span class="cm-word">$let</span> <span class="cm-word">:=</span> <span class="cm-word">"let"</span><span class="cm-tag">&lt;/let&gt;</span> <span class="cm-keyword">return</span> <span class="cm-keyword">element</span> <span class="cm-word">element</span> { <span class="cm-keyword">attribute</span> <span class="cm-word">attribute</span> { <span class="cm-keyword">try</span> { <span class="cm-variable cm-def">xdmp:version</span>() } <span class="cm-keyword">catch</span>(<span class="cm-variable">$e</span>) { <span class="cm-variable cm-def">xdmp:log</span>(<span class="cm-variable">$e</span>) } }, <span class="cm-keyword">attribute</span> <span class="cm-word">fn:doc</span> { <span class="cm-string">"bar"</span> <span class="cm-word">castable</span> <span class="cm-keyword">as</span> <span class="cm-atom">xs:string</span> }, <span class="cm-keyword">element</span> <span class="cm-word">text</span> { <span class="cm-keyword">text</span> { <span class="cm-string">"text"</span> } }, <span class="cm-variable cm-def">fn:doc</span>()[ <span class="cm-qualifier">child::</span><span class="cm-word">eq</span><span class="cm-keyword">/</span>(<span class="cm-word">@bar</span> <span class="cm-keyword">|</span> <span class="cm-qualifier">attribute::</span><span class="cm-word">attribute</span>) <span class="cm-keyword">eq</span> <span class="cm-variable">$let</span> ], <span class="cm-keyword">//</span><span class="cm-word">fn:doc</span> }';
34
35 $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
36 var editor = CodeMirror.fromTextArea($("#editor")[0]);
37 var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
38
39 equal(result, expected);
40 $("#editor").html("");
41 });
42 });