1
0

test.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "css");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. // Error, because "foobarhello" is neither a known type or property, but
  7. // property was expected (after "and"), and it should be in parenthese.
  8. MT("atMediaUnknownType",
  9. "[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
  10. // Soft error, because "foobarhello" is not a known property or type.
  11. MT("atMediaUnknownProperty",
  12. "[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
  13. // Make sure nesting works with media queries
  14. MT("atMediaMaxWidthNested",
  15. "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
  16. MT("tagSelector",
  17. "[tag foo] { }");
  18. MT("classSelector",
  19. "[qualifier .foo-bar_hello] { }");
  20. MT("idSelector",
  21. "[builtin #foo] { [error #foo] }");
  22. MT("tagSelectorUnclosed",
  23. "[tag foo] { [property margin]: [number 0] } [tag bar] { }");
  24. MT("tagStringNoQuotes",
  25. "[tag foo] { [property font-family]: [variable hello] [variable world]; }");
  26. MT("tagStringDouble",
  27. "[tag foo] { [property font-family]: [string \"hello world\"]; }");
  28. MT("tagStringSingle",
  29. "[tag foo] { [property font-family]: [string 'hello world']; }");
  30. MT("tagColorKeyword",
  31. "[tag foo] {",
  32. " [property color]: [keyword black];",
  33. " [property color]: [keyword navy];",
  34. " [property color]: [keyword yellow];",
  35. "}");
  36. MT("tagColorHex3",
  37. "[tag foo] { [property background]: [atom #fff]; }");
  38. MT("tagColorHex6",
  39. "[tag foo] { [property background]: [atom #ffffff]; }");
  40. MT("tagColorHex4",
  41. "[tag foo] { [property background]: [atom&error #ffff]; }");
  42. MT("tagColorHexInvalid",
  43. "[tag foo] { [property background]: [atom&error #ffg]; }");
  44. MT("tagNegativeNumber",
  45. "[tag foo] { [property margin]: [number -5px]; }");
  46. MT("tagPositiveNumber",
  47. "[tag foo] { [property padding]: [number 5px]; }");
  48. MT("tagVendor",
  49. "[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
  50. MT("tagBogusProperty",
  51. "[tag foo] { [property&error barhelloworld]: [number 0]; }");
  52. MT("tagTwoProperties",
  53. "[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
  54. MT("tagTwoPropertiesURL",
  55. "[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
  56. MT("commentSGML",
  57. "[comment <!--comment-->]");
  58. MT("commentSGML2",
  59. "[comment <!--comment]",
  60. "[comment -->] [tag div] {}");
  61. MT("indent_tagSelector",
  62. "[tag strong], [tag em] {",
  63. " [property background]: [atom rgba](",
  64. " [number 255], [number 255], [number 0], [number .2]",
  65. " );",
  66. "}");
  67. MT("indent_atMedia",
  68. "[def @media] {",
  69. " [tag foo] {",
  70. " [property color]:",
  71. " [keyword yellow];",
  72. " }",
  73. "}");
  74. MT("indent_comma",
  75. "[tag foo] {",
  76. " [property font-family]: [variable verdana],",
  77. " [atom sans-serif];",
  78. "}");
  79. MT("indent_parentheses",
  80. "[tag foo]:[variable-3 before] {",
  81. " [property background]: [atom url](",
  82. "[string blahblah]",
  83. "[string etc]",
  84. "[string ]) [keyword !important];",
  85. "}");
  86. MT("font_face",
  87. "[def @font-face] {",
  88. " [property font-family]: [string 'myfont'];",
  89. " [error nonsense]: [string 'abc'];",
  90. " [property src]: [atom url]([string http://blah]),",
  91. " [atom url]([string http://foo]);",
  92. "}");
  93. MT("empty_url",
  94. "[def @import] [tag url]() [tag screen];");
  95. MT("parens",
  96. "[qualifier .foo] {",
  97. " [property background-image]: [variable fade]([atom #000], [number 20%]);",
  98. " [property border-image]: [variable linear-gradient](",
  99. " [atom to] [atom bottom],",
  100. " [variable fade]([atom #000], [number 20%]) [number 0%],",
  101. " [variable fade]([atom #000], [number 20%]) [number 100%]",
  102. " );",
  103. "}");
  104. })();