less_test.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. ;(function () {
  4. 'use strict'
  5. var mode = CodeMirror.getMode({ indentUnit: 2 }, 'text/x-less')
  6. function MT(name) {
  7. test.mode(name, mode, Array.prototype.slice.call(arguments, 1), 'less')
  8. }
  9. MT(
  10. 'variable',
  11. '[variable-2 @base]: [atom #f04615];',
  12. '[qualifier .class] {',
  13. ' [property width]: [variable&callee percentage]([number 0.5]); [comment // returns `50%`]',
  14. ' [property color]: [variable&callee saturate]([variable-2 @base], [number 5%]);',
  15. '}'
  16. )
  17. MT(
  18. 'amp',
  19. '[qualifier .child], [qualifier .sibling] {',
  20. ' [qualifier .parent] [atom &] {',
  21. ' [property color]: [keyword black];',
  22. ' }',
  23. ' [atom &] + [atom &] {',
  24. ' [property color]: [keyword red];',
  25. ' }',
  26. '}'
  27. )
  28. MT(
  29. 'mixin',
  30. '[qualifier .mixin] ([variable dark]; [variable-2 @color]) {',
  31. ' [property color]: [variable&callee darken]([variable-2 @color], [number 10%]);',
  32. '}',
  33. '[qualifier .mixin] ([variable light]; [variable-2 @color]) {',
  34. ' [property color]: [variable&callee lighten]([variable-2 @color], [number 10%]);',
  35. '}',
  36. '[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {',
  37. ' [property display]: [atom block];',
  38. '}',
  39. '[variable-2 @switch]: [variable light];',
  40. '[qualifier .class] {',
  41. ' [qualifier .mixin]([variable-2 @switch]; [atom #888]);',
  42. '}'
  43. )
  44. MT(
  45. 'nest',
  46. '[qualifier .one] {',
  47. ' [def @media] ([property width]: [number 400px]) {',
  48. ' [property font-size]: [number 1.2em];',
  49. ' [def @media] [attribute print] [keyword and] [property color] {',
  50. ' [property color]: [keyword blue];',
  51. ' }',
  52. ' }',
  53. '}'
  54. )
  55. MT('interpolation', '.@{[variable foo]} { [property font-weight]: [atom bold]; }')
  56. })()