jscript: Added object to number conversion implementation.
[wine] / dlls / jscript / tests / regexp.js
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19
20 var m;
21
22 m = "abcabc".match(/ca/);
23 ok(typeof(m) === "object", "typeof m is not object");
24 ok(m.length === 1, "m.length is not 1");
25 ok(m["0"] === "ca", "m[0] is not \"ca\"");
26
27 m = "abcabc".match(/ab/);
28 ok(typeof(m) === "object", "typeof m is not object");
29 ok(m.length === 1, "m.length is not 1");
30 ok(m["0"] === "ab", "m[0] is not \"ab\"");
31
32 m = "abcabc".match(/ab/g);
33 ok(typeof(m) === "object", "typeof m is not object");
34 ok(m.length === 2, "m.length is not 1");
35 ok(m["0"] === "ab", "m[0] is not \"ab\"");
36 ok(m["1"] === "ab", "m[1] is not \"ab\"");
37
38 m = "abcabc".match(/Ab/g);
39 ok(typeof(m) === "object", "typeof m is not object");
40 ok(m === null, "m is not null");
41
42 m = "abcabc".match(/Ab/gi);
43 ok(typeof(m) === "object", "typeof m is not object");
44 ok(m.length === 2, "m.length is not 1");
45 ok(m["0"] === "ab", "m[0] is not \"ab\"");
46 ok(m["1"] === "ab", "m[1] is not \"ab\"");
47
48 m = "aaabcabc".match(/a+b/g);
49 ok(typeof(m) === "object", "typeof m is not object");
50 ok(m.length === 2, "m.length is not 1");
51 ok(m["0"] === "aaab", "m[0] is not \"ab\"");
52 ok(m["1"] === "ab", "m[1] is not \"ab\"");
53
54 m = "abcabc".match(new RegExp("ab"));
55 ok(typeof(m) === "object", "typeof m is not object");
56 ok(m.length === 1, "m.length is not 1");
57 ok(m["0"] === "ab", "m[0] is not \"ab\"");
58
59 /*
60 m = "abcabc".match(new RegExp("ab","g"));
61 ok(typeof(m) === "object", "typeof m is not object");
62 ok(m.length === 2, "m.length is not 1");
63 ok(m["0"] === "ab", "m[0] is not \"ab\"");
64 ok(m["1"] === "ab", "m[1] is not \"ab\"");
65
66 m = "abcabc".match(new RegExp(/ab/g));
67 ok(typeof(m) === "object", "typeof m is not object");
68 ok(m.length === 2, "m.length is not 1");
69 ok(m["0"] === "ab", "m[0] is not \"ab\"");
70 ok(m["1"] === "ab", "m[1] is not \"ab\"");
71
72 m = "abcabc".match(new RegExp("ab","g", "test"));
73 ok(typeof(m) === "object", "typeof m is not object");
74 ok(m.length === 2, "m.length is not 1");
75 ok(m["0"] === "ab", "m[0] is not \"ab\"");
76 ok(m["1"] === "ab", "m[1] is not \"ab\"");
77 */
78 reportSuccess();