testIteratorObject.cpp (1111B)
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/. */ 4 5 #include "js/Class.h" // js::ESClass 6 #include "js/Object.h" // JS::GetBuiltinClass 7 #include "js/RootingAPI.h" // JS::Rooted 8 #include "js/Value.h" // JS::Value 9 #include "jsapi-tests/tests.h" 10 11 BEGIN_TEST(testIteratorObject) { 12 using js::ESClass; 13 14 JS::Rooted<JS::Value> result(cx); 15 16 EVAL("new Map([['key1', 'value1'], ['key2', 'value2']]).entries()", &result); 17 18 CHECK(result.isObject()); 19 JS::Rooted<JSObject*> obj1(cx, &result.toObject()); 20 ESClass class1 = ESClass::Other; 21 CHECK(JS::GetBuiltinClass(cx, obj1, &class1)); 22 CHECK(class1 == ESClass::MapIterator); 23 24 EVAL("new Set(['value1', 'value2']).entries()", &result); 25 26 CHECK(result.isObject()); 27 JS::Rooted<JSObject*> obj2(cx, &result.toObject()); 28 ESClass class2 = ESClass::Other; 29 CHECK(JS::GetBuiltinClass(cx, obj2, &class2)); 30 CHECK(class2 == ESClass::SetIterator); 31 32 return true; 33 } 34 END_TEST(testIteratorObject)