1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "js/RegExpFlags.h"
7 #include "jsapi-tests/tests.h"
9 BEGIN_TEST(testObjectIsRegExp
) {
10 JS::RootedValue
val(cx
);
14 EVAL("new Object", &val
);
15 JS::RootedObject
obj(cx
, val
.toObjectOrNull());
16 CHECK(JS::ObjectIsRegExp(cx
, obj
, &isRegExp
));
19 EVAL("/foopy/", &val
);
20 obj
= val
.toObjectOrNull();
21 CHECK(JS::ObjectIsRegExp(cx
, obj
, &isRegExp
));
26 END_TEST(testObjectIsRegExp
)
28 BEGIN_TEST(testGetRegExpFlags
) {
29 JS::RootedValue
val(cx
);
30 JS::RootedObject
obj(cx
);
32 EVAL("/foopy/", &val
);
33 obj
= val
.toObjectOrNull();
34 CHECK_EQUAL(JS::GetRegExpFlags(cx
, obj
),
35 JS::RegExpFlags(JS::RegExpFlag::NoFlags
));
37 EVAL("/foopy/g", &val
);
38 obj
= val
.toObjectOrNull();
39 CHECK_EQUAL(JS::GetRegExpFlags(cx
, obj
),
40 JS::RegExpFlags(JS::RegExpFlag::Global
));
42 EVAL("/foopy/gi", &val
);
43 obj
= val
.toObjectOrNull();
45 JS::GetRegExpFlags(cx
, obj
),
46 JS::RegExpFlags(JS::RegExpFlag::Global
| JS::RegExpFlag::IgnoreCase
));
50 END_TEST(testGetRegExpFlags
)
52 BEGIN_TEST(testGetRegExpSource
) {
53 JS::RootedValue
val(cx
);
54 JS::RootedObject
obj(cx
);
56 EVAL("/foopy/", &val
);
57 obj
= val
.toObjectOrNull();
58 JSString
* source
= JS::GetRegExpSource(cx
, obj
);
60 CHECK(JS_LinearStringEqualsLiteral(JS_ASSERT_STRING_IS_LINEAR(source
),
65 END_TEST(testGetRegExpSource
)