test.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "xml"), mname = "xml";
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), mname); }
  6. MT("matching",
  7. "[tag&bracket <][tag top][tag&bracket >]",
  8. " text",
  9. " [tag&bracket <][tag inner][tag&bracket />]",
  10. "[tag&bracket </][tag top][tag&bracket >]");
  11. MT("nonmatching",
  12. "[tag&bracket <][tag top][tag&bracket >]",
  13. " [tag&bracket <][tag inner][tag&bracket />]",
  14. " [tag&bracket </][tag&error tip][tag&bracket&error >]");
  15. MT("doctype",
  16. "[meta <!doctype foobar>]",
  17. "[tag&bracket <][tag top][tag&bracket />]");
  18. MT("cdata",
  19. "[tag&bracket <][tag top][tag&bracket >]",
  20. " [atom <![CDATA[foo]",
  21. "[atom barbazguh]]]]>]",
  22. "[tag&bracket </][tag top][tag&bracket >]");
  23. // HTML tests
  24. mode = CodeMirror.getMode({indentUnit: 2}, "text/html");
  25. MT("selfclose",
  26. "[tag&bracket <][tag html][tag&bracket >]",
  27. " [tag&bracket <][tag link] [attribute rel]=[string stylesheet] [attribute href]=[string \"/foobar\"][tag&bracket >]",
  28. "[tag&bracket </][tag html][tag&bracket >]");
  29. MT("list",
  30. "[tag&bracket <][tag ol][tag&bracket >]",
  31. " [tag&bracket <][tag li][tag&bracket >]one",
  32. " [tag&bracket <][tag li][tag&bracket >]two",
  33. "[tag&bracket </][tag ol][tag&bracket >]");
  34. MT("valueless",
  35. "[tag&bracket <][tag input] [attribute type]=[string checkbox] [attribute checked][tag&bracket />]");
  36. MT("pThenArticle",
  37. "[tag&bracket <][tag p][tag&bracket >]",
  38. " foo",
  39. "[tag&bracket <][tag article][tag&bracket >]bar");
  40. })();