Bug 1716030 [wpt PR 29346] - Update wpt metadata, a=testonly
[gecko.git] / js / src / jsapi-tests / testInformalValueTypeName.cpp
blob37b73ccc08ab39cf45729720aee433ffa3464e20
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "js/Array.h" // JS::NewArrayObject
9 #include "js/Symbol.h"
10 #include "jsapi-tests/tests.h"
12 BEGIN_TEST(testInformalValueTypeName) {
13 JS::RootedValue v1(cx, JS::ObjectOrNullValue(JS_NewPlainObject(cx)));
14 CHECK(strcmp(JS::InformalValueTypeName(v1), "Object") == 0);
16 JS::RootedValue v2(cx, JS::ObjectOrNullValue(JS::NewArrayObject(cx, 0)));
17 CHECK(strcmp(JS::InformalValueTypeName(v2), "Array") == 0);
19 JS::RootedValue v3(cx, JS::StringValue(JS_GetEmptyString(cx)));
20 CHECK(strcmp(JS::InformalValueTypeName(v3), "string") == 0);
22 JS::RootedValue v4(cx, JS::SymbolValue(JS::NewSymbol(cx, nullptr)));
23 CHECK(strcmp(JS::InformalValueTypeName(v4), "symbol") == 0);
25 JS::RootedValue v5(cx, JS::NumberValue(50.5));
26 CHECK(strcmp(JS::InformalValueTypeName(v5), "number") == 0);
27 JS::RootedValue v6(cx, JS::Int32Value(50));
28 CHECK(strcmp(JS::InformalValueTypeName(v6), "number") == 0);
29 JS::RootedValue v7(cx, JS::Float32Value(50.5));
30 CHECK(strcmp(JS::InformalValueTypeName(v7), "number") == 0);
32 JS::RootedValue v8(cx, JS::TrueValue());
33 CHECK(strcmp(JS::InformalValueTypeName(v8), "boolean") == 0);
35 JS::RootedValue v9(cx, JS::NullValue());
36 CHECK(strcmp(JS::InformalValueTypeName(v9), "null") == 0);
38 JS::RootedValue v10(cx, JS::UndefinedValue());
39 CHECK(strcmp(JS::InformalValueTypeName(v10), "undefined") == 0);
41 return true;
43 END_TEST(testInformalValueTypeName)