mirror of https://github.com/svaarala/duktape.git
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.
61 lines
787 B
61 lines
787 B
12 years ago
|
/*
|
||
|
* Test() should have the same behavior as exec(), except that the return
|
||
|
* value is just a boolean.
|
||
|
*/
|
||
|
|
||
|
var r, t;
|
||
|
|
||
|
/*===
|
||
|
true
|
||
|
false
|
||
|
===*/
|
||
|
|
||
|
try {
|
||
|
r = /foo/;
|
||
|
t = r.test('foo');
|
||
|
print(t);
|
||
|
t = r.test('bar');
|
||
|
print(t);
|
||
|
} catch (e) {
|
||
|
print(e.name);
|
||
|
}
|
||
|
|
||
|
/*===
|
||
|
true
|
||
|
false
|
||
|
===*/
|
||
|
|
||
|
try {
|
||
|
r = /(foo)/i;
|
||
|
t = r.test('Foo');
|
||
|
print(t);
|
||
|
t = r.test('bar');
|
||
|
print(t);
|
||
|
} catch (e) {
|
||
|
print(e.name);
|
||
|
}
|
||
|
|
||
|
/*===
|
||
|
0
|
||
|
true 3
|
||
|
true 6
|
||
|
true 9
|
||
|
false 0
|
||
|
===*/
|
||
|
|
||
|
try {
|
||
|
r = /foo/gi;
|
||
|
print(r.lastIndex);
|
||
|
t = r.test('fooFooFOO');
|
||
|
print(t, r.lastIndex);
|
||
|
t = r.test('fooFooFOO');
|
||
|
print(t, r.lastIndex);
|
||
|
t = r.test('fooFooFOO');
|
||
|
print(t, r.lastIndex);
|
||
|
t = r.test('fooFooFOO');
|
||
|
print(t, r.lastIndex);
|
||
|
} catch (e) {
|
||
|
print(e.name);
|
||
|
}
|
||
|
|