Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | (function() { |
michael@0 | 2 | var mode = CodeMirror.getMode({indentUnit: 2}, "javascript"); |
michael@0 | 3 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } |
michael@0 | 4 | |
michael@0 | 5 | MT("locals", |
michael@0 | 6 | "[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }"); |
michael@0 | 7 | |
michael@0 | 8 | MT("comma-and-binop", |
michael@0 | 9 | "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }"); |
michael@0 | 10 | |
michael@0 | 11 | MT("destructuring", |
michael@0 | 12 | "([keyword function]([def a], [[[def b], [def c] ]]) {", |
michael@0 | 13 | " [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);", |
michael@0 | 14 | " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];", |
michael@0 | 15 | "})();"); |
michael@0 | 16 | |
michael@0 | 17 | MT("class", |
michael@0 | 18 | "[keyword class] [variable Point] [keyword extends] [variable SuperThing] {", |
michael@0 | 19 | " [[ [string-2 /expr/] ]]: [number 24],", |
michael@0 | 20 | " [property constructor]([def x], [def y]) {", |
michael@0 | 21 | " [keyword super]([string 'something']);", |
michael@0 | 22 | " [keyword this].[property x] [operator =] [variable-2 x];", |
michael@0 | 23 | " }", |
michael@0 | 24 | "}"); |
michael@0 | 25 | |
michael@0 | 26 | MT("module", |
michael@0 | 27 | "[keyword module] [string 'foo'] {", |
michael@0 | 28 | " [keyword export] [keyword let] [def x] [operator =] [number 42];", |
michael@0 | 29 | " [keyword export] [keyword *] [keyword from] [string 'somewhere'];", |
michael@0 | 30 | "}"); |
michael@0 | 31 | |
michael@0 | 32 | MT("import", |
michael@0 | 33 | "[keyword function] [variable foo]() {", |
michael@0 | 34 | " [keyword import] [def $] [keyword from] [string 'jquery'];", |
michael@0 | 35 | " [keyword module] [def crypto] [keyword from] [string 'crypto'];", |
michael@0 | 36 | " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];", |
michael@0 | 37 | "}"); |
michael@0 | 38 | |
michael@0 | 39 | MT("const", |
michael@0 | 40 | "[keyword function] [variable f]() {", |
michael@0 | 41 | " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];", |
michael@0 | 42 | "}"); |
michael@0 | 43 | |
michael@0 | 44 | MT("for/of", |
michael@0 | 45 | "[keyword for]([keyword let] [variable of] [keyword of] [variable something]) {}"); |
michael@0 | 46 | |
michael@0 | 47 | MT("generator", |
michael@0 | 48 | "[keyword function*] [variable repeat]([def n]) {", |
michael@0 | 49 | " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])", |
michael@0 | 50 | " [keyword yield] [variable-2 i];", |
michael@0 | 51 | "}"); |
michael@0 | 52 | |
michael@0 | 53 | MT("fatArrow", |
michael@0 | 54 | "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);", |
michael@0 | 55 | "[variable a];", // No longer in scope |
michael@0 | 56 | "[keyword let] [variable f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", |
michael@0 | 57 | "[variable c];"); |
michael@0 | 58 | |
michael@0 | 59 | MT("spread", |
michael@0 | 60 | "[keyword function] [variable f]([def a], [meta ...][def b]) {", |
michael@0 | 61 | " [variable something]([variable-2 a], [meta ...][variable-2 b]);", |
michael@0 | 62 | "}"); |
michael@0 | 63 | |
michael@0 | 64 | MT("comprehension", |
michael@0 | 65 | "[keyword function] [variable f]() {", |
michael@0 | 66 | " [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];", |
michael@0 | 67 | " ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));", |
michael@0 | 68 | "}"); |
michael@0 | 69 | |
michael@0 | 70 | MT("quasi", |
michael@0 | 71 | "[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); |
michael@0 | 72 | |
michael@0 | 73 | MT("indent_statement", |
michael@0 | 74 | "[keyword var] [variable x] [operator =] [number 10]", |
michael@0 | 75 | "[variable x] [operator +=] [variable y] [operator +]", |
michael@0 | 76 | " [atom Infinity]", |
michael@0 | 77 | "[keyword debugger];"); |
michael@0 | 78 | |
michael@0 | 79 | MT("indent_if", |
michael@0 | 80 | "[keyword if] ([number 1])", |
michael@0 | 81 | " [keyword break];", |
michael@0 | 82 | "[keyword else] [keyword if] ([number 2])", |
michael@0 | 83 | " [keyword continue];", |
michael@0 | 84 | "[keyword else]", |
michael@0 | 85 | " [number 10];", |
michael@0 | 86 | "[keyword if] ([number 1]) {", |
michael@0 | 87 | " [keyword break];", |
michael@0 | 88 | "} [keyword else] [keyword if] ([number 2]) {", |
michael@0 | 89 | " [keyword continue];", |
michael@0 | 90 | "} [keyword else] {", |
michael@0 | 91 | " [number 10];", |
michael@0 | 92 | "}"); |
michael@0 | 93 | |
michael@0 | 94 | MT("indent_for", |
michael@0 | 95 | "[keyword for] ([keyword var] [variable i] [operator =] [number 0];", |
michael@0 | 96 | " [variable i] [operator <] [number 100];", |
michael@0 | 97 | " [variable i][operator ++])", |
michael@0 | 98 | " [variable doSomething]([variable i]);", |
michael@0 | 99 | "[keyword debugger];"); |
michael@0 | 100 | |
michael@0 | 101 | MT("indent_c_style", |
michael@0 | 102 | "[keyword function] [variable foo]()", |
michael@0 | 103 | "{", |
michael@0 | 104 | " [keyword debugger];", |
michael@0 | 105 | "}"); |
michael@0 | 106 | |
michael@0 | 107 | MT("multilinestring", |
michael@0 | 108 | "[keyword var] [variable x] [operator =] [string 'foo\\]", |
michael@0 | 109 | "[string bar'];"); |
michael@0 | 110 | |
michael@0 | 111 | MT("scary_regexp", |
michael@0 | 112 | "[string-2 /foo[[/]]bar/];"); |
michael@0 | 113 | |
michael@0 | 114 | var jsonld_mode = CodeMirror.getMode( |
michael@0 | 115 | {indentUnit: 2}, |
michael@0 | 116 | {name: "javascript", jsonld: true} |
michael@0 | 117 | ); |
michael@0 | 118 | function LD(name) { |
michael@0 | 119 | test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1)); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | LD("json_ld_keywords", |
michael@0 | 123 | '{', |
michael@0 | 124 | ' [meta "@context"]: {', |
michael@0 | 125 | ' [meta "@base"]: [string "http://example.com"],', |
michael@0 | 126 | ' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],', |
michael@0 | 127 | ' [property "likesFlavor"]: {', |
michael@0 | 128 | ' [meta "@container"]: [meta "@list"]', |
michael@0 | 129 | ' [meta "@reverse"]: [string "@beFavoriteOf"]', |
michael@0 | 130 | ' },', |
michael@0 | 131 | ' [property "nick"]: { [meta "@container"]: [meta "@set"] },', |
michael@0 | 132 | ' [property "nick"]: { [meta "@container"]: [meta "@index"] }', |
michael@0 | 133 | ' },', |
michael@0 | 134 | ' [meta "@graph"]: [[ {', |
michael@0 | 135 | ' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],', |
michael@0 | 136 | ' [property "name"]: [string "John Lennon"],', |
michael@0 | 137 | ' [property "modified"]: {', |
michael@0 | 138 | ' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],', |
michael@0 | 139 | ' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]', |
michael@0 | 140 | ' }', |
michael@0 | 141 | ' } ]]', |
michael@0 | 142 | '}'); |
michael@0 | 143 | |
michael@0 | 144 | LD("json_ld_fake", |
michael@0 | 145 | '{', |
michael@0 | 146 | ' [property "@fake"]: [string "@fake"],', |
michael@0 | 147 | ' [property "@contextual"]: [string "@identifier"],', |
michael@0 | 148 | ' [property "user@domain.com"]: [string "@graphical"],', |
michael@0 | 149 | ' [property "@ID"]: [string "@@ID"]', |
michael@0 | 150 | '}'); |
michael@0 | 151 | })(); |