Bug 1285909 - Part 2: Add test coverage for IsMapObject and IsSetObject. r=jorendorff.
authorNicolas Auvray <na.itms76@gmail.com>
Sat, 10 Dec 2016 12:19:02 +0100
changeset 415482 a1e3dce97e85597982416ffb9dc8f81ac9c56bc2
parent 415481 82e125c825cef4f087473e9637a8d5f11c9680d5
child 415483 4aeafd05a3b20e23248868beb5e8b950dda50866
push id33896
push userrgurzau@mozilla.com
push dateWed, 25 Apr 2018 09:36:32 +0000
treeherdermozilla-central@a83a4ef50f6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1285909
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1285909 - Part 2: Add test coverage for IsMapObject and IsSetObject. r=jorendorff.
js/src/jsapi-tests/testNewObject.cpp
--- a/js/src/jsapi-tests/testNewObject.cpp
+++ b/js/src/jsapi-tests/testNewObject.cpp
@@ -114,8 +114,40 @@ BEGIN_TEST(testNewObject_1)
     obj = JS_New(cx, ctor, JS::HandleValueArray::subarray(argv, 0, 3));
     CHECK(obj);
     CHECK(JS_GetElement(cx, ctor, 0, &v));
     CHECK(v.isInt32(0));
 
     return true;
 }
 END_TEST(testNewObject_1)
+
+BEGIN_TEST(testNewObject_IsMapObject)
+{
+    // Test IsMapObject and IsSetObject
+
+    JS::RootedValue vMap(cx);
+    EVAL("Map", &vMap);
+    JS::RootedObject Map(cx, vMap.toObjectOrNull());
+
+    bool isMap = false;
+    bool isSet = false;
+    JS::RootedObject mapObj(cx, JS_New(cx, Map, JS::HandleValueArray::empty()));
+    CHECK(mapObj);
+    CHECK(JS::IsMapObject(cx, mapObj, &isMap));
+    CHECK(isMap);
+    CHECK(JS::IsSetObject(cx, mapObj, &isSet));
+    CHECK(!isSet);
+
+    JS::RootedValue vSet(cx);
+    EVAL("Set", &vSet);
+    JS::RootedObject Set(cx, vSet.toObjectOrNull());
+
+    JS::RootedObject setObj(cx, JS_New(cx, Set, JS::HandleValueArray::empty()));
+    CHECK(setObj);
+    CHECK(JS::IsMapObject(cx, setObj, &isMap));
+    CHECK(!isMap);
+    CHECK(JS::IsSetObject(cx, setObj, &isSet));
+    CHECK(isSet);
+
+    return true;
+}
+END_TEST(testNewObject_IsMapObject)