You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.3 KiB
135 lines
3.3 KiB
/* test.js - test for javascript.xml syntax file */
|
|
// Note: this script will not, and is not supposed to, comile in any js engine.
|
|
|
|
/*
|
|
NOTE: The words "todo", "fixme" and "note" should be rendered in a different style
|
|
within comments, match should be caseless (to test for regexp insensitive attribute).
|
|
The regex used for this rule is */
|
|
String = /\b(?:fixme|todo|note)\b/
|
|
/* Thus, for example "Notebook" is not caught by
|
|
this rule. (the "?:" in the subpattern is there to avoid the regex engine wasting time
|
|
saving a backref, which is not used for anything. I do not know if the overhead of parsing
|
|
that is greater than the time saved by not capturing the text...)
|
|
The rule for catching these words is placed in a context "Comment common", which is used
|
|
by both comment contexts (single line, multiline) using the new "IncludeRules" item.
|
|
*/
|
|
|
|
// test if regex support works - nice with new fallthrough prop in context:)
|
|
somestring.replace( /dooh/ , "bah!");
|
|
re=/foo/ig; // hehe
|
|
|
|
somestring.search(
|
|
/^foo\w+\s\d{0,15}$/
|
|
);
|
|
|
|
re =
|
|
/dooh/;
|
|
|
|
// This is supposedly legal:
|
|
re = somebool ? /foo/ : /bar/;
|
|
|
|
// NOTE - Special case: an empty regex, not a comment.
|
|
// The rule uses a positive lookahead assertion to catch it: "//(?=;)".
|
|
re = //;
|
|
re = /a|b/;
|
|
|
|
/*
|
|
Tests for the regex parser.
|
|
It will parse classes, quanitfiers, special characters and regex operaters,
|
|
as specified in the netscape documentation for javascript.
|
|
Regexps are only parsed in their clean form, as the RegExp(string) constructor
|
|
is using a quoted string.
|
|
TODO: Find out if more regex feats should be supported.
|
|
Consider using more itemDatas - assertion, quantifier are options.
|
|
*/
|
|
|
|
re = /^text\s+\d+\s*$/;
|
|
re = /a pattern with caret \(^\) in it/;
|
|
re = /(\d{0,4})\D/;
|
|
re = /[a-zA-Z_]+/;
|
|
re = /[^\d^]+/;
|
|
re = /\s+?\w+\.$/;
|
|
re = /\/\//;
|
|
re = /a|b/;
|
|
|
|
// a test if #pop back from a comment will work
|
|
re = /*/foo/*/ /bar/;
|
|
// ^ POP
|
|
// ^ we got back after pop in comment, if there is regexp attribs here :-)
|
|
|
|
/*
|
|
Some tests if the fallthrough works.
|
|
The fallthrough happens if a regexp is not found in a possible (!) position,
|
|
which is after "search(" or "replace(" or "=" or "?" or ":" in version 0.1 of the xml file
|
|
*/
|
|
|
|
var foo = 'bar';
|
|
// ^ fallthrough!
|
|
|
|
|
|
somestring.replace( new RegExp("\\b\\w+\\b"), "word: $1");
|
|
// ^ fallthrough expected. ("new" whould be bold)
|
|
|
|
|
|
something.method =
|
|
function ( a, b, c ) { /* ... */ }
|
|
// ^ fallthrough ?!
|
|
|
|
something.other =
|
|
function ( d, e, f ) { /* ... */ }
|
|
// fallthrough expected at col 0 ("function" should be bold)
|
|
|
|
var ary = new Array(5);
|
|
// ^ fallthrough ? (if keyword is correctly rendered)
|
|
|
|
var b = a ? 1 : 0;
|
|
// ^ ^ fallthroughs. numbers must be rendered correctly.
|
|
|
|
var c = d ? true : false;
|
|
|
|
var conditinalstring = b ?
|
|
"something" :
|
|
"something else";
|
|
// guess...
|
|
|
|
|
|
/*
|
|
Normal program flow...
|
|
*/
|
|
|
|
if (something)
|
|
dostuff();
|
|
else
|
|
dont();
|
|
|
|
return;
|
|
|
|
try { bla() } catch (e) { alert("ERROR! : " + e) }
|
|
|
|
for (int i=0; i < j; i++)
|
|
document.write("i is" + i + "<br>");
|
|
|
|
while (something)
|
|
{
|
|
block();
|
|
picky:
|
|
if (!1)
|
|
break;
|
|
else
|
|
continue;
|
|
}
|
|
|
|
with (a) {
|
|
do {
|
|
stuff( b ); // a.b if it exists
|
|
} while (itmakessense);
|
|
}
|
|
|
|
switch (i) {
|
|
case 0:
|
|
f();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|