From 671d2b94996ac71d56b2d05d5fe694ed7d84fa59 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 4 Apr 2012 12:27:35 -0700 Subject: upgrading to CodeMirror 2.23, since it has an important fix to Not close Ninja, if backspace is pressed while autocomplete dropdown is open. Signed-off-by: Ananya Sen --- imports/codemirror/mode/xquery/test/index.html | 27 +++++++ imports/codemirror/mode/xquery/test/testBase.js | 42 ++++++++++ .../mode/xquery/test/testEmptySequenceKeyword.js | 16 ++++ .../codemirror/mode/xquery/test/testMultiAttr.js | 16 ++++ .../codemirror/mode/xquery/test/testNamespaces.js | 91 ++++++++++++++++++++++ .../mode/xquery/test/testProcessingInstructions.js | 16 ++++ imports/codemirror/mode/xquery/test/testQuotes.js | 19 +++++ 7 files changed, 227 insertions(+) create mode 100644 imports/codemirror/mode/xquery/test/index.html create mode 100644 imports/codemirror/mode/xquery/test/testBase.js create mode 100644 imports/codemirror/mode/xquery/test/testEmptySequenceKeyword.js create mode 100644 imports/codemirror/mode/xquery/test/testMultiAttr.js create mode 100644 imports/codemirror/mode/xquery/test/testNamespaces.js create mode 100644 imports/codemirror/mode/xquery/test/testProcessingInstructions.js create mode 100644 imports/codemirror/mode/xquery/test/testQuotes.js (limited to 'imports/codemirror/mode/xquery/test') diff --git a/imports/codemirror/mode/xquery/test/index.html b/imports/codemirror/mode/xquery/test/index.html new file mode 100644 index 00000000..ba82e54f --- /dev/null +++ b/imports/codemirror/mode/xquery/test/index.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + +

XQuery CodeMirror Mode

+

+

+
    +
+
+ + 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 @@ + $(document).ready(function(){ + module("testBase"); + test("eviltest", function() { + expect(1); + + var input = 'xquery version "1.0-ml";\ + (: this is\ + : a \ + "comment" :)\ + let $let := <x attr="value">"test"<func>function() $var {function()} {$var}</func></x>\ + let $joe:=1\ + return element element {\ + attribute attribute { 1 },\ + element test { 'a' }, \ + attribute foo { "bar" },\ + fn:doc()[ foo/@bar eq $let ],\ + //x } \ + \ + (: a more \'evil\' test :)\ + (: Modified Blakeley example (: with nested comment :) ... :)\ + declare private function local:declare() {()};\ + declare private function local:private() {()};\ + declare private function local:function() {()};\ + declare private function local:local() {()};\ + let $let := <let>let $let := "let"</let>\ + return element element {\ + attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },\ + attribute fn:doc { "bar" castable as xs:string },\ + element text { text { "text" } },\ + fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],\ + //fn:doc\ + }'; + var expected = 'xquery version "1.0-ml"; (: this is : a "comment" :) let $let := <x attr="value">"test"<func>function() $var {function()} {$var}</func></x> let $joe:=1 return element element { attribute attribute { 1 }, element test { \'a\' }, attribute foo { "bar" }, fn:doc()[ foo/@bar eq $let ], //x } (: a more \'evil\' test :) (: Modified Blakeley example (: with nested comment :) ... :) declare private function local:declare() {()}; declare private function local:private() {()}; declare private function local:function() {()}; declare private function local:local() {()}; let $let := <let>let $let := "let"</let> return element element { attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } }, attribute fn:doc { "bar" castable as xs:string }, element text { text { "text" } }, fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ], //fn:doc }'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + }); diff --git a/imports/codemirror/mode/xquery/test/testEmptySequenceKeyword.js b/imports/codemirror/mode/xquery/test/testEmptySequenceKeyword.js new file mode 100644 index 00000000..39ed0905 --- /dev/null +++ b/imports/codemirror/mode/xquery/test/testEmptySequenceKeyword.js @@ -0,0 +1,16 @@ +$(document).ready(function(){ + module("testEmptySequenceKeyword"); + test("testEmptySequenceKeyword", function() { + expect(1); + + var input = '"foo" instance of empty-sequence()'; + var expected = '"foo" instance of empty-sequence()'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); +}); diff --git a/imports/codemirror/mode/xquery/test/testMultiAttr.js b/imports/codemirror/mode/xquery/test/testMultiAttr.js new file mode 100644 index 00000000..8e98c47d --- /dev/null +++ b/imports/codemirror/mode/xquery/test/testMultiAttr.js @@ -0,0 +1,16 @@ + $(document).ready(function(){ + module("testMultiAttr"); + test("test1", function() { + expect(1); + + var expected = '<p a1="foo" a2="bar">hello world</p>'; + + $("#sandbox").html(''); + $("#editor").html('

hello world

'); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + }); \ No newline at end of file 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 @@ +$(document).ready(function(){ + module("test namespaces"); + +// -------------------------------------------------------------------------------- +// this test is based on this: +//http://mbrevoort.github.com/CodeMirror2/#!exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-10.xq +// -------------------------------------------------------------------------------- + test("test namespaced variable", function() { + expect(1); + + var input = 'declare namespace e = "http://example.com/ANamespace";\ +declare variable $e:exampleComThisVarIsNotRecognized as element(*) external;'; + + var expected = 'declare namespace e = "http://example.com/ANamespace";declare variable $e:exampleComThisVarIsNotRecognized as element(*) external;'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + + +// -------------------------------------------------------------------------------- +// this test is based on: +// http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-002.xq +// -------------------------------------------------------------------------------- + test("test EQName variable", function() { + expect(1); + + var input = 'declare variable $"http://www.example.com/ns/my":var := 12;\ +{$"http://www.example.com/ns/my":var}'; + + var expected = 'declare variable $"http://www.example.com/ns/my":var := 12;<out>{$"http://www.example.com/ns/my":var}</out>'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + +// -------------------------------------------------------------------------------- +// this test is based on: +// http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-003.xq +// -------------------------------------------------------------------------------- + test("test EQName function", function() { + expect(1); + + var input = 'declare function "http://www.example.com/ns/my":fn ($a as xs:integer) as xs:integer {\ + $a + 2\ +};\ +{"http://www.example.com/ns/my":fn(12)}'; + + var expected = 'declare function "http://www.example.com/ns/my":fn ($a as xs:integer) as xs:integer { $a + 2};<out>{"http://www.example.com/ns/my":fn(12)}</out>'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + +// -------------------------------------------------------------------------------- +// this test is based on: +// http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-003.xq +// -------------------------------------------------------------------------------- + test("test EQName function with single quotes", function() { + expect(1); + + var input = 'declare function \'http://www.example.com/ns/my\':fn ($a as xs:integer) as xs:integer {\ + $a + 2\ +};\ +{\'http://www.example.com/ns/my\':fn(12)}'; + + var expected = 'declare function \'http://www.example.com/ns/my\':fn ($a as xs:integer) as xs:integer { $a + 2};<out>{\'http://www.example.com/ns/my\':fn(12)}</out>'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + +}); + + diff --git a/imports/codemirror/mode/xquery/test/testProcessingInstructions.js b/imports/codemirror/mode/xquery/test/testProcessingInstructions.js new file mode 100644 index 00000000..9b753052 --- /dev/null +++ b/imports/codemirror/mode/xquery/test/testProcessingInstructions.js @@ -0,0 +1,16 @@ +$(document).ready(function(){ + module("testProcessingInstructions"); + test("testProcessingInstructions", function() { + expect(1); + + var input = 'data() instance of xs:string'; + var expected = 'data(<?target content?>) instance of xs:string'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); +}); diff --git a/imports/codemirror/mode/xquery/test/testQuotes.js b/imports/codemirror/mode/xquery/test/testQuotes.js new file mode 100644 index 00000000..79e5142d --- /dev/null +++ b/imports/codemirror/mode/xquery/test/testQuotes.js @@ -0,0 +1,19 @@ + $(document).ready(function(){ + module("testQuoteEscape"); + test("testQuoteEscapeDouble", function() { + expect(1); + + var input = 'let $rootfolder := "c:\\builds\\winnt\\HEAD\\qa\\scripts\\"\ +let $keysfolder := concat($rootfolder, "keys\\")\ +return\ +$keysfolder'; + var expected = 'let $rootfolder := "c:\\builds\\winnt\\HEAD\\qa\\scripts\\"let $keysfolder := concat($rootfolder, "keys\\")return$keysfolder'; + + $("#sandbox").html(''); + var editor = CodeMirror.fromTextArea($("#editor")[0]); + var result = $(".CodeMirror-lines div div pre")[0].innerHTML; + + equal(result, expected); + $("#editor").html(""); + }); + }); -- cgit v1.2.3