less_test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. (function() {
  2. "use strict";
  3. var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
  4. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
  5. MT("variable",
  6. "[variable-2 @base]: [atom #f04615];",
  7. "[qualifier .class] {",
  8. " [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]",
  9. " [property color]: [variable saturate]([variable-2 @base], [number 5%]);",
  10. "}");
  11. MT("amp",
  12. "[qualifier .child], [qualifier .sibling] {",
  13. " [qualifier .parent] [atom &] {",
  14. " [property color]: [keyword black];",
  15. " }",
  16. " [atom &] + [atom &] {",
  17. " [property color]: [keyword red];",
  18. " }",
  19. "}");
  20. MT("mixin",
  21. "[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
  22. " [property color]: [variable darken]([variable-2 @color], [number 10%]);",
  23. "}",
  24. "[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
  25. " [property color]: [variable lighten]([variable-2 @color], [number 10%]);",
  26. "}",
  27. "[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
  28. " [property display]: [atom block];",
  29. "}",
  30. "[variable-2 @switch]: [variable light];",
  31. "[qualifier .class] {",
  32. " [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
  33. "}");
  34. MT("nest",
  35. "[qualifier .one] {",
  36. " [def @media] ([property width]: [number 400px]) {",
  37. " [property font-size]: [number 1.2em];",
  38. " [def @media] [attribute print] [keyword and] [property color] {",
  39. " [property color]: [keyword blue];",
  40. " }",
  41. " }",
  42. "}");
  43. })();