2025-03-19 21:25:58 +10:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
|
* vim: set ts=8 sw=4 et tw=99:
|
|
|
|
|
*/
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "tests.h"
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsstr.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
BEGIN_TEST(testIntString_bug515273)
|
|
|
|
|
{
|
|
|
|
|
jsvalRoot v(cx);
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
EVAL("'1';", v.addr());
|
2025-02-05 12:40:54 +10:00
|
|
|
JSString *str = JSVAL_TO_STRING(v.value());
|
2025-03-19 21:25:58 +10:00
|
|
|
CHECK(JSString::isStatic(str));
|
|
|
|
|
CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "1"));
|
|
|
|
|
|
|
|
|
|
EVAL("'42';", v.addr());
|
|
|
|
|
str = JSVAL_TO_STRING(v.value());
|
|
|
|
|
CHECK(JSString::isStatic(str));
|
|
|
|
|
CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "42"));
|
|
|
|
|
|
|
|
|
|
EVAL("'111';", v.addr());
|
|
|
|
|
str = JSVAL_TO_STRING(v.value());
|
|
|
|
|
CHECK(JSString::isStatic(str));
|
|
|
|
|
CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "111"));
|
|
|
|
|
|
|
|
|
|
/* Test other types of static strings. */
|
|
|
|
|
EVAL("'a';", v.addr());
|
|
|
|
|
str = JSVAL_TO_STRING(v.value());
|
|
|
|
|
CHECK(JSString::isStatic(str));
|
|
|
|
|
CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "a"));
|
|
|
|
|
|
|
|
|
|
EVAL("'bc';", v.addr());
|
|
|
|
|
str = JSVAL_TO_STRING(v.value());
|
|
|
|
|
CHECK(JSString::isStatic(str));
|
|
|
|
|
CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "bc"));
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
END_TEST(testIntString_bug515273)
|