File modules/editor/codemirror/mode/javascript/test.min.js
Last commit: Tue May 22 22:39:55 2018 +0200 Jan Dankert Fix für PHP 7.2: 'Object' darf nun nicht mehr als Klassennamen verwendet werden. AUCH NICHT IN EINEM NAMESPACE! WTF, wozu habe ich das in einen verfickten Namespace gepackt? Wozu soll der sonst da sein??? Amateure. Daher nun notgedrungen unbenannt in 'BaseObject'.
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({indentUnit: 2}, "javascript"); 6 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 7 8 MT("locals", 9 "[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }"); 10 11 MT("comma-and-binop", 12 "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }"); 13 14 MT("destructuring", 15 "([keyword function]([def a], [[[def b], [def c] ]]) {", 16 " [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);", 17 " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];", 18 "})();"); 19 20 MT("destructure_trailing_comma", 21 "[keyword let] {[def a], [def b],} [operator =] [variable foo];", 22 "[keyword let] [def c];"); // Parser still in good state? 23 24 MT("class_body", 25 "[keyword class] [def Foo] {", 26 " [property constructor]() {}", 27 " [property sayName]() {", 28 " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];", 29 " }", 30 "}"); 31 32 MT("class", 33 "[keyword class] [def Point] [keyword extends] [variable SuperThing] {", 34 " [keyword get] [property prop]() { [keyword return] [number 24]; }", 35 " [property constructor]([def x], [def y]) {", 36 " [keyword super]([string 'something']);", 37 " [keyword this].[property x] [operator =] [variable-2 x];", 38 " }", 39 "}"); 40 41 MT("anonymous_class_expression", 42 "[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {", 43 " [property add]([def a], [def b]) {}", 44 "};"); 45 46 MT("named_class_expression", 47 "[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {", 48 " [property sub]([def a], [def b]) {}", 49 "};"); 50 51 MT("class_async_method", 52 "[keyword class] [def Foo] {", 53 " [property sayName1]() {}", 54 " [keyword async] [property sayName2]() {}", 55 "}"); 56 57 MT("import", 58 "[keyword function] [def foo]() {", 59 " [keyword import] [def $] [keyword from] [string 'jquery'];", 60 " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];", 61 "}"); 62 63 MT("import_trailing_comma", 64 "[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']") 65 66 MT("const", 67 "[keyword function] [def f]() {", 68 " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];", 69 "}"); 70 71 MT("for/of", 72 "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}"); 73 74 MT("generator", 75 "[keyword function*] [def repeat]([def n]) {", 76 " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])", 77 " [keyword yield] [variable-2 i];", 78 "}"); 79 80 MT("quotedStringAddition", 81 "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];"); 82 83 MT("quotedFatArrow", 84 "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];"); 85 86 MT("fatArrow", 87 "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);", 88 "[variable a];", // No longer in scope 89 "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", 90 "[variable c];"); 91 92 MT("spread", 93 "[keyword function] [def f]([def a], [meta ...][def b]) {", 94 " [variable something]([variable-2 a], [meta ...][variable-2 b]);", 95 "}"); 96 97 MT("quasi", 98 "[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); 99 100 MT("quasi_no_function", 101 "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); 102 103 MT("indent_statement", 104 "[keyword var] [def x] [operator =] [number 10]", 105 "[variable x] [operator +=] [variable y] [operator +]", 106 " [atom Infinity]", 107 "[keyword debugger];"); 108 109 MT("indent_if", 110 "[keyword if] ([number 1])", 111 " [keyword break];", 112 "[keyword else] [keyword if] ([number 2])", 113 " [keyword continue];", 114 "[keyword else]", 115 " [number 10];", 116 "[keyword if] ([number 1]) {", 117 " [keyword break];", 118 "} [keyword else] [keyword if] ([number 2]) {", 119 " [keyword continue];", 120 "} [keyword else] {", 121 " [number 10];", 122 "}"); 123 124 MT("indent_for", 125 "[keyword for] ([keyword var] [def i] [operator =] [number 0];", 126 " [variable i] [operator <] [number 100];", 127 " [variable i][operator ++])", 128 " [variable doSomething]([variable i]);", 129 "[keyword debugger];"); 130 131 MT("indent_c_style", 132 "[keyword function] [def foo]()", 133 "{", 134 " [keyword debugger];", 135 "}"); 136 137 MT("indent_else", 138 "[keyword for] (;;)", 139 " [keyword if] ([variable foo])", 140 " [keyword if] ([variable bar])", 141 " [number 1];", 142 " [keyword else]", 143 " [number 2];", 144 " [keyword else]", 145 " [number 3];"); 146 147 MT("indent_funarg", 148 "[variable foo]([number 10000],", 149 " [keyword function]([def a]) {", 150 " [keyword debugger];", 151 "};"); 152 153 MT("indent_below_if", 154 "[keyword for] (;;)", 155 " [keyword if] ([variable foo])", 156 " [number 1];", 157 "[number 2];"); 158 159 MT("indent_semicolonless_if", 160 "[keyword function] [def foo]() {", 161 " [keyword if] ([variable x])", 162 " [variable foo]()", 163 "}") 164 165 MT("indent_semicolonless_if_with_statement", 166 "[keyword function] [def foo]() {", 167 " [keyword if] ([variable x])", 168 " [variable foo]()", 169 " [variable bar]()", 170 "}") 171 172 MT("multilinestring", 173 "[keyword var] [def x] [operator =] [string 'foo\\]", 174 "[string bar'];"); 175 176 MT("scary_regexp", 177 "[string-2 /foo[[/]]bar/];"); 178 179 MT("indent_strange_array", 180 "[keyword var] [def x] [operator =] [[", 181 " [number 1],,", 182 " [number 2],", 183 "]];", 184 "[number 10];"); 185 186 MT("param_default", 187 "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {", 188 " [keyword return] [variable-2 x];", 189 "}"); 190 191 MT("new_target", 192 "[keyword function] [def F]([def target]) {", 193 " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {", 194 " [keyword return] [keyword new]", 195 " .[keyword target];", 196 " }", 197 "}"); 198 199 MT("async", 200 "[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); 201 202 MT("async_assignment", 203 "[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };"); 204 205 MT("async_object", 206 "[keyword let] [def obj] [operator =] { [property async]: [atom false] };"); 207 208 // async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173 209 MT("async_object_function", 210 "[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };"); 211 212 MT("async_object_properties", 213 "[keyword let] [def obj] [operator =] {", 214 " [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", 215 " [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", 216 " [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },", 217 "};"); 218 219 MT("async_arrow", 220 "[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };"); 221 222 MT("async_jquery", 223 "[variable $].[property ajax]({", 224 " [property url]: [variable url],", 225 " [property async]: [atom true],", 226 " [property method]: [string 'GET']", 227 "});"); 228 229 MT("async_variable", 230 "[keyword const] [def async] [operator =] {[property a]: [number 1]};", 231 "[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];") 232 233 MT("async_comment", 234 "[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); 235 236 MT("indent_switch", 237 "[keyword switch] ([variable x]) {", 238 " [keyword default]:", 239 " [keyword return] [number 2]", 240 "}") 241 242 MT("regexp_corner_case", 243 "[operator +]{} [operator /] [atom undefined];", 244 "[[[meta ...][string-2 /\\//] ]];", 245 "[keyword void] [string-2 /\\//];", 246 "[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);", 247 "[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];", 248 "[string-2 `${][variable async][operator ++][string-2 }//`];", 249 "[string-2 `${]{} [operator /] [string-2 /\\//}`];") 250 251 MT("return_eol", 252 "[keyword return]", 253 "{} [string-2 /5/]") 254 255 var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript") 256 function TS(name) { 257 test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) 258 } 259 260 TS("typescript_extend_type", 261 "[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}") 262 263 TS("typescript_arrow_type", 264 "[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]") 265 266 TS("typescript_class", 267 "[keyword class] [def Foo] {", 268 " [keyword public] [keyword static] [property main]() {}", 269 " [keyword private] [property _foo]: [type string];", 270 "}") 271 272 TS("typescript_literal_types", 273 "[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];", 274 "[keyword interface] [def MyAttributes] {", 275 " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", 276 " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", 277 "}", 278 "[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {", 279 " [property rawAttributes]: [type MyAttributes];", 280 " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", 281 " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", 282 "}") 283 284 TS("typescript_extend_operators", 285 "[keyword export] [keyword interface] [def UserModel] [keyword extends]", 286 " [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {", 287 " [property findById]: (", 288 " [variable userId]: [type number]", 289 " ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];", 290 " [property updateById]: (", 291 " [variable userId]: [type number],", 292 " [variable isActive]: [type boolean]", 293 " ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];", 294 " }") 295 296 TS("typescript_interface_with_const", 297 "[keyword const] [def hello]: {", 298 " [property prop1][operator ?]: [type string];", 299 " [property prop2][operator ?]: [type string];", 300 "} [operator =] {};") 301 302 TS("typescript_double_extend", 303 "[keyword export] [keyword interface] [def UserAttributes] {", 304 " [property id][operator ?]: [type number];", 305 " [property createdAt][operator ?]: [type Date];", 306 "}", 307 "[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {", 308 " [property id]: [type number];", 309 " [property createdAt]: [type Date];", 310 "}"); 311 312 TS("typescript_index_signature", 313 "[keyword interface] [def A] {", 314 " [[ [variable prop]: [type string] ]]: [type any];", 315 " [property prop1]: [type any];", 316 "}"); 317 318 TS("typescript_generic_class", 319 "[keyword class] [def Foo][operator <][type T][operator >] {", 320 " [property bar]() {}", 321 " [property foo](): [type Foo] {}", 322 "}") 323 324 TS("typescript_type_when_keyword", 325 "[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];", 326 "[keyword type] [type Flags] [operator =] {", 327 " [property p1]: [type string];", 328 " [property p2]: [type boolean];", 329 "};") 330 331 TS("typescript_type_when_not_keyword", 332 "[keyword class] [def HasType] {", 333 " [property type]: [type string];", 334 " [property constructor]([def type]: [type string]) {", 335 " [keyword this].[property type] [operator =] [variable-2 type];", 336 " }", 337 " [property setType]({ [def type] }: { [property type]: [type string]; }) {", 338 " [keyword this].[property type] [operator =] [variable-2 type];", 339 " }", 340 "}") 341 342 TS("typescript_function_generics", 343 "[keyword function] [def a]() {}", 344 "[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}", 345 "[keyword function] [def c]() {}") 346 347 TS("typescript_complex_return_type", 348 "[keyword function] [def A]() {", 349 " [keyword return] [keyword this].[property property];", 350 "}", 351 "[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {", 352 " [keyword return] [keyword this].[property property];", 353 "}") 354 355 TS("typescript_complex_type_casting", 356 "[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };") 357 358 TS("typescript_keyof", 359 "[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {", 360 " [keyword return]") 361 362 TS("typescript_new_typeargs", 363 "[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])") 364 365 TS("modifiers", 366 "[keyword class] [def Foo] {", 367 " [keyword public] [keyword abstract] [property bar]() {}", 368 " [property constructor]([keyword readonly] [keyword private] [def x]) {}", 369 "}") 370 371 TS("arrow prop", 372 "({[property a]: [def p] [operator =>] [variable-2 p]})") 373 374 TS("generic in function call", 375 "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);", 376 "[keyword this].[property a][operator <][variable Type][operator >][variable foo];") 377 378 TS("type guard", 379 "[keyword class] [def Appler] {", 380 " [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {", 381 " [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))", 382 " [keyword throw] [keyword new] [variable Error]();", 383 " }", 384 "}") 385 386 var jsonld_mode = CodeMirror.getMode( 387 {indentUnit: 2}, 388 {name: "javascript", jsonld: true} 389 ); 390 function LD(name) { 391 test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1)); 392 } 393 394 LD("json_ld_keywords", 395 '{', 396 ' [meta "@context"]: {', 397 ' [meta "@base"]: [string "http://example.com"],', 398 ' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],', 399 ' [property "likesFlavor"]: {', 400 ' [meta "@container"]: [meta "@list"]', 401 ' [meta "@reverse"]: [string "@beFavoriteOf"]', 402 ' },', 403 ' [property "nick"]: { [meta "@container"]: [meta "@set"] },', 404 ' [property "nick"]: { [meta "@container"]: [meta "@index"] }', 405 ' },', 406 ' [meta "@graph"]: [[ {', 407 ' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],', 408 ' [property "name"]: [string "John Lennon"],', 409 ' [property "modified"]: {', 410 ' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],', 411 ' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]', 412 ' }', 413 ' } ]]', 414 '}'); 415 416 LD("json_ld_fake", 417 '{', 418 ' [property "@fake"]: [string "@fake"],', 419 ' [property "@contextual"]: [string "@identifier"],', 420 ' [property "user@domain.com"]: [string "@graphical"],', 421 ' [property "@ID"]: [string "@@ID"]', 422 '}'); 423 })();
Downloadmodules/editor/codemirror/mode/javascript/test.min.js
History Tue, 22 May 2018 22:39:55 +0200 Jan Dankert Fix für PHP 7.2: 'Object' darf nun nicht mehr als Klassennamen verwendet werden. AUCH NICHT IN EINEM NAMESPACE! WTF, wozu habe ich das in einen verfickten Namespace gepackt? Wozu soll der sonst da sein??? Amateure. Daher nun notgedrungen unbenannt in 'BaseObject'.