Bug 880330 - Refactor the jsapi-tests to use the new options API; r=bholley

This commit is contained in:
Eddy Bruel 2013-10-14 13:36:42 +02:00
parent f662b56dc7
commit c25117dc6e
4 changed files with 14 additions and 10 deletions

View File

@ -131,8 +131,10 @@ virtual
JSContext *createContext() JSContext *createContext()
{ {
JSContext *cx = JSAPITest::createContext(); JSContext *cx = JSAPITest::createContext();
if (cx) if (!cx)
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_BASELINE | JSOPTION_ION); return NULL;
ContextOptionsRef(cx).setBaseline(true)
.setIon(true);
return cx; return cx;
} }

View File

@ -9,8 +9,7 @@ BEGIN_TEST(testJSEvaluateScript)
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, global)); JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, global));
CHECK(obj); CHECK(obj);
uint32_t options = JS_GetOptions(cx); CHECK(ContextOptionsRef(cx).varObjFix());
CHECK(options & JSOPTION_VAROBJFIX);
static const char src[] = "var x = 5;"; static const char src[] = "var x = 5;";
@ -27,7 +26,7 @@ BEGIN_TEST(testJSEvaluateScript)
CHECK(hasProp); CHECK(hasProp);
// Now do the same thing, but without JSOPTION_VAROBJFIX // Now do the same thing, but without JSOPTION_VAROBJFIX
JS_SetOptions(cx, options & ~JSOPTION_VAROBJFIX); ContextOptionsRef(cx).setVarObjFix(false);
static const char src2[] = "var y = 5;"; static const char src2[] = "var y = 5;";

View File

@ -141,7 +141,8 @@ END_TEST(testProfileStrings_isCalledWithInterpreter)
BEGIN_TEST(testProfileStrings_isCalledWithJIT) BEGIN_TEST(testProfileStrings_isCalledWithJIT)
{ {
CHECK(initialize(cx)); CHECK(initialize(cx));
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_BASELINE | JSOPTION_ION); ContextOptionsRef(cx).setBaseline(true)
.setIon(true);
EXEC("function g() { var p = new Prof(); p.test_fn(); }"); EXEC("function g() { var p = new Prof(); p.test_fn(); }");
EXEC("function f() { g(); }"); EXEC("function f() { g(); }");
@ -189,12 +190,13 @@ END_TEST(testProfileStrings_isCalledWithJIT)
BEGIN_TEST(testProfileStrings_isCalledWhenError) BEGIN_TEST(testProfileStrings_isCalledWhenError)
{ {
CHECK(initialize(cx)); CHECK(initialize(cx));
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_BASELINE | JSOPTION_ION); ContextOptionsRef(cx).setBaseline(true)
.setIon(true);
EXEC("function check2() { throw 'a'; }"); EXEC("function check2() { throw 'a'; }");
reset(cx); reset(cx);
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_DONT_REPORT_UNCAUGHT); ContextOptionsRef(cx).setDontReportUncaught(true);
{ {
JS::RootedValue rval(cx); JS::RootedValue rval(cx);
/* Make sure the stack resets and we have an entry for each stack */ /* Make sure the stack resets and we have an entry for each stack */
@ -212,7 +214,8 @@ END_TEST(testProfileStrings_isCalledWhenError)
BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly) BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
{ {
CHECK(initialize(cx)); CHECK(initialize(cx));
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_BASELINE | JSOPTION_ION); ContextOptionsRef(cx).setBaseline(true)
.setIon(true);
EXEC("function b(p) { p.test_fn(); }"); EXEC("function b(p) { p.test_fn(); }");
EXEC("function a() { var p = new Prof(); p.enable(); b(p); }"); EXEC("function a() { var p = new Prof(); p.enable(); b(p); }");

View File

@ -300,7 +300,7 @@ class JSAPITest
JSContext *cx = JS_NewContext(rt, 8192); JSContext *cx = JS_NewContext(rt, 8192);
if (!cx) if (!cx)
return nullptr; return nullptr;
JS_SetOptions(cx, JSOPTION_VAROBJFIX); ContextOptionsRef(cx).setVarObjFix(true);
JS_SetErrorReporter(cx, &reportError); JS_SetErrorReporter(cx, &reportError);
return cx; return cx;
} }