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 6f550cca37
commit c589d6fe48
4 changed files with 14 additions and 10 deletions

View File

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

View File

@ -9,8 +9,7 @@ BEGIN_TEST(testJSEvaluateScript)
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, global));
CHECK(obj);
uint32_t options = JS_GetOptions(cx);
CHECK(options & JSOPTION_VAROBJFIX);
CHECK(ContextOptionsRef(cx).varObjFix());
static const char src[] = "var x = 5;";
@ -27,7 +26,7 @@ BEGIN_TEST(testJSEvaluateScript)
CHECK(hasProp);
// 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;";

View File

@ -141,7 +141,8 @@ END_TEST(testProfileStrings_isCalledWithInterpreter)
BEGIN_TEST(testProfileStrings_isCalledWithJIT)
{
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 f() { g(); }");
@ -189,12 +190,13 @@ END_TEST(testProfileStrings_isCalledWithJIT)
BEGIN_TEST(testProfileStrings_isCalledWhenError)
{
CHECK(initialize(cx));
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_BASELINE | JSOPTION_ION);
ContextOptionsRef(cx).setBaseline(true)
.setIon(true);
EXEC("function check2() { throw 'a'; }");
reset(cx);
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_DONT_REPORT_UNCAUGHT);
ContextOptionsRef(cx).setDontReportUncaught(true);
{
JS::RootedValue rval(cx);
/* 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)
{
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 a() { var p = new Prof(); p.enable(); b(p); }");

View File

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