test.js (3010B)
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 4 (function() { 5 var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "haml"); 6 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 7 8 // Requires at least one media query 9 MT("elementName", 10 "[tag %h1] Hey There"); 11 12 MT("oneElementPerLine", 13 "[tag %h1] Hey There %h2"); 14 15 MT("idSelector", 16 "[tag %h1][attribute #test] Hey There"); 17 18 MT("classSelector", 19 "[tag %h1][attribute .hello] Hey There"); 20 21 MT("docType", 22 "[tag !!! XML]"); 23 24 MT("comment", 25 "[comment / Hello WORLD]"); 26 27 MT("notComment", 28 "[tag %h1] This is not a / comment "); 29 30 MT("attributes", 31 "[tag %a]([variable title][operator =][string \"test\"]){[atom :title] [operator =>] [string \"test\"]}"); 32 33 MT("htmlCode", 34 "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket </][tag h1][tag&bracket >]"); 35 36 MT("rubyBlock", 37 "[operator =][variable-2 @item]"); 38 39 MT("selectorRubyBlock", 40 "[tag %a.selector=] [variable-2 @item]"); 41 42 MT("nestedRubyBlock", 43 "[tag %a]", 44 " [operator =][variable puts] [string \"test\"]"); 45 46 MT("multilinePlaintext", 47 "[tag %p]", 48 " Hello,", 49 " World"); 50 51 MT("multilineRuby", 52 "[tag %p]", 53 " [comment -# this is a comment]", 54 " [comment and this is a comment too]", 55 " Date/Time", 56 " [operator -] [variable now] [operator =] [tag DateTime][operator .][property now]", 57 " [tag %strong=] [variable now]", 58 " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])", 59 " [operator =][string \"Happy\"]", 60 " [operator =][string \"Belated\"]", 61 " [operator =][string \"Birthday\"]"); 62 63 MT("multilineComment", 64 "[comment /]", 65 " [comment Multiline]", 66 " [comment Comment]"); 67 68 MT("hamlComment", 69 "[comment -# this is a comment]"); 70 71 MT("multilineHamlComment", 72 "[comment -# this is a comment]", 73 " [comment and this is a comment too]"); 74 75 MT("multilineHTMLComment", 76 "[comment <!--]", 77 " [comment what a comment]", 78 " [comment -->]"); 79 80 MT("hamlAfterRubyTag", 81 "[attribute .block]", 82 " [tag %strong=] [variable now]", 83 " [attribute .test]", 84 " [operator =][variable now]", 85 " [attribute .right]"); 86 87 MT("stretchedRuby", 88 "[operator =] [variable puts] [string \"Hello\"],", 89 " [string \"World\"]"); 90 91 MT("interpolationInHashAttribute", 92 //"[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test"); 93 "[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test"); 94 95 MT("interpolationInHTMLAttribute", 96 "[tag %div]([variable title][operator =][string \"#{][variable test][string }_#{][variable ting]()[string }\"]) Test"); 97 })();