summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/misc/regexp-functions-with-undefined.js
blob: e55b2acd0725305b4069df448855fcb39844b444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

var a = /undefined/.exec();
assertEq(a[0], 'undefined');
assertEq(a.length, 1);

a = /undefined/.exec(undefined);
assertEq(a[0], 'undefined');
assertEq(a.length, 1);

assertEq(/undefined/.test(), true);
assertEq(/undefined/.test(undefined), true);

assertEq(/aaaa/.exec(), null);
assertEq(/aaaa/.exec(undefined), null);

assertEq(/aaaa/.test(), false);
assertEq(/aaaa/.test(undefined), false);


assertEq("undefined".search(), 0);
assertEq("undefined".search(undefined), 0);
assertEq("aaaa".search(), 0);
assertEq("aaaa".search(undefined), 0);

a = "undefined".match();
assertEq(a[0], "");
assertEq(a.length, 1);
a = "undefined".match(undefined);
assertEq(a[0], "");
assertEq(a.length, 1);
a = "aaaa".match();
assertEq(a[0], "");
assertEq(a.length, 1);
a = "aaaa".match(undefined);
assertEq(a[0], "");
assertEq(a.length, 1);

if (typeof reportCompare === "function")
    reportCompare(true, true);