michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "jsapi-tests/tests.h" michael@0: michael@0: BEGIN_TEST(testIntString_bug515273) michael@0: { michael@0: JS::RootedValue v(cx); michael@0: michael@0: EVAL("'1';", &v); michael@0: JSString *str = JSVAL_TO_STRING(v); michael@0: CHECK(JS_StringHasBeenInterned(cx, str)); michael@0: CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "1")); michael@0: michael@0: EVAL("'42';", &v); michael@0: str = JSVAL_TO_STRING(v); michael@0: CHECK(JS_StringHasBeenInterned(cx, str)); michael@0: CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "42")); michael@0: michael@0: EVAL("'111';", &v); michael@0: str = JSVAL_TO_STRING(v); michael@0: CHECK(JS_StringHasBeenInterned(cx, str)); michael@0: CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "111")); michael@0: michael@0: /* Test other types of static strings. */ michael@0: EVAL("'a';", &v); michael@0: str = JSVAL_TO_STRING(v); michael@0: CHECK(JS_StringHasBeenInterned(cx, str)); michael@0: CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "a")); michael@0: michael@0: EVAL("'bc';", &v); michael@0: str = JSVAL_TO_STRING(v); michael@0: CHECK(JS_StringHasBeenInterned(cx, str)); michael@0: CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "bc")); michael@0: michael@0: return true; michael@0: } michael@0: END_TEST(testIntString_bug515273)