1
0

test.js 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Don't take these too seriously -- the expected results appear to be
  2. // based on the results of actual runs without any serious manual
  3. // verification. If a change you made causes them to fail, the test is
  4. // as likely to wrong as the code.
  5. (function() {
  6. var mode = CodeMirror.getMode({tabSize: 4}, "xquery");
  7. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  8. MT("eviltest",
  9. "[keyword xquery] [keyword version] [variable "1][keyword .][atom 0][keyword -][variable ml"][def&variable ;] [comment (: this is : a \"comment\" :)]",
  10. " [keyword let] [variable $let] [keyword :=] [variable <x] [variable attr][keyword =][variable "value">"test"<func&gt][def&variable ;function]() [variable $var] {[keyword function]()} {[variable $var]}[variable <][keyword /][variable func><][keyword /][variable x>]",
  11. " [keyword let] [variable $joe][keyword :=][atom 1]",
  12. " [keyword return] [keyword element] [variable element] {",
  13. " [keyword attribute] [variable attribute] { [atom 1] },",
  14. " [keyword element] [variable test] { [variable 'a'] }, [keyword attribute] [variable foo] { [variable "bar"] },",
  15. " [def&variable fn:doc]()[[ [variable foo][keyword /][variable @bar] [keyword eq] [variable $let] ]],",
  16. " [keyword //][variable x] } [comment (: a more 'evil' test :)]",
  17. " [comment (: Modified Blakeley example (: with nested comment :) ... :)]",
  18. " [keyword declare] [keyword private] [keyword function] [def&variable local:declare]() {()}[variable ;]",
  19. " [keyword declare] [keyword private] [keyword function] [def&variable local:private]() {()}[variable ;]",
  20. " [keyword declare] [keyword private] [keyword function] [def&variable local:function]() {()}[variable ;]",
  21. " [keyword declare] [keyword private] [keyword function] [def&variable local:local]() {()}[variable ;]",
  22. " [keyword let] [variable $let] [keyword :=] [variable <let>let] [variable $let] [keyword :=] [variable "let"<][keyword /let][variable >]",
  23. " [keyword return] [keyword element] [variable element] {",
  24. " [keyword attribute] [variable attribute] { [keyword try] { [def&variable xdmp:version]() } [keyword catch]([variable $e]) { [def&variable xdmp:log]([variable $e]) } },",
  25. " [keyword attribute] [variable fn:doc] { [variable "bar"] [variable castable] [keyword as] [atom xs:string] },",
  26. " [keyword element] [variable text] { [keyword text] { [variable "text"] } },",
  27. " [def&variable fn:doc]()[[ [qualifier child::][variable eq][keyword /]([variable @bar] [keyword |] [qualifier attribute::][variable attribute]) [keyword eq] [variable $let] ]],",
  28. " [keyword //][variable fn:doc]",
  29. " }");
  30. MT("testEmptySequenceKeyword",
  31. "[string \"foo\"] [keyword instance] [keyword of] [keyword empty-sequence]()");
  32. MT("testMultiAttr",
  33. "[tag <p ][attribute a1]=[string \"foo\"] [attribute a2]=[string \"bar\"][tag >][variable hello] [variable world][tag </p>]");
  34. MT("test namespaced variable",
  35. "[keyword declare] [keyword namespace] [variable e] [keyword =] [string \"http://example.com/ANamespace\"][variable ;declare] [keyword variable] [variable $e:exampleComThisVarIsNotRecognized] [keyword as] [keyword element]([keyword *]) [variable external;]");
  36. MT("test EQName variable",
  37. "[keyword declare] [keyword variable] [variable $\"http://www.example.com/ns/my\":var] [keyword :=] [atom 12][variable ;]",
  38. "[tag <out>]{[variable $\"http://www.example.com/ns/my\":var]}[tag </out>]");
  39. MT("test EQName function",
  40. "[keyword declare] [keyword function] [def&variable \"http://www.example.com/ns/my\":fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {",
  41. " [variable $a] [keyword +] [atom 2]",
  42. "}[variable ;]",
  43. "[tag <out>]{[def&variable \"http://www.example.com/ns/my\":fn]([atom 12])}[tag </out>]");
  44. MT("test EQName function with single quotes",
  45. "[keyword declare] [keyword function] [def&variable 'http://www.example.com/ns/my':fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {",
  46. " [variable $a] [keyword +] [atom 2]",
  47. "}[variable ;]",
  48. "[tag <out>]{[def&variable 'http://www.example.com/ns/my':fn]([atom 12])}[tag </out>]");
  49. MT("testProcessingInstructions",
  50. "[def&variable data]([comment&meta <?target content?>]) [keyword instance] [keyword of] [atom xs:string]");
  51. MT("testQuoteEscapeDouble",
  52. "[keyword let] [variable $rootfolder] [keyword :=] [string \"c:\\builds\\winnt\\HEAD\\qa\\scripts\\\"]",
  53. "[keyword let] [variable $keysfolder] [keyword :=] [def&variable concat]([variable $rootfolder], [string \"keys\\\"])");
  54. })();