本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
5.0KB

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