Skip to content

Commit 4b92709

Browse files
committed
Update testlib.cpp
1 parent d233588 commit 4b92709

File tree

1 file changed

+37
-45
lines changed
  • vnext/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test

1 file changed

+37
-45
lines changed

vnext/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp

+37-45
Original file line numberDiff line numberDiff line change
@@ -1488,48 +1488,44 @@ TEST_P(JSITest, NativeState) {
14881488
std::dynamic_pointer_cast<IntState>(holder.getNativeState(rt))->value,
14891489
21);
14901490

1491-
// There's currently way to "delete" the native state of a component fully
1492-
// Even when reset with nullptr, hasNativeState will still return true
1493-
// TODO: Make it pass for Hermes and V8
1494-
// holder.setNativeState(rt, nullptr);
1495-
// EXPECT_TRUE(holder.hasNativeState(rt));
1496-
// EXPECT_TRUE(holder.getNativeState(rt) == nullptr);
1491+
holder.setNativeState(rt, nullptr);
1492+
EXPECT_TRUE(holder.hasNativeState(rt));
1493+
EXPECT_TRUE(holder.getNativeState(rt) == nullptr);
14971494
}
14981495

1499-
// TODO: Make it pass on Hermes
1500-
// TEST_P(JSITest, NativeStateSymbolOverrides) {
1501-
// Object holder(rt);
1502-
1503-
// auto stateValue = std::make_shared<IntState>(42);
1504-
// holder.setNativeState(rt, stateValue);
1505-
1506-
// // Attempting to change configurable attribute of unconfigurable property
1507-
// try {
1508-
// function(
1509-
// "function (obj) {"
1510-
// " var mySymbol = Symbol();"
1511-
// " obj[mySymbol] = 'foo';"
1512-
// " var allSymbols = Object.getOwnPropertySymbols(obj);"
1513-
// " for (var sym of allSymbols) {"
1514-
// " Object.defineProperty(obj, sym, {configurable: true, writable:
1515-
// true});" " obj[sym] = 'bar';" " }"
1516-
// "}")
1517-
// .call(rt, holder);
1518-
// } catch (const JSError& ex) {
1519-
// // On JSC this throws, but it doesn't on Hermes
1520-
// std::string exc = ex.what();
1521-
// EXPECT_NE(
1522-
// exc.find(
1523-
// "Attempting to change configurable attribute of unconfigurable
1524-
// property"),
1525-
// std::string::npos);
1526-
// }
1527-
1528-
// EXPECT_TRUE(holder.hasNativeState(rt));
1529-
// EXPECT_EQ(
1530-
// std::dynamic_pointer_cast<IntState>(holder.getNativeState(rt))->value,
1531-
// 42);
1532-
// }
1496+
TEST_P(JSITest, NativeStateSymbolOverrides) {
1497+
Object holder(rt);
1498+
1499+
auto stateValue = std::make_shared<IntState>(42);
1500+
holder.setNativeState(rt, stateValue);
1501+
1502+
// Attempting to change configurable attribute of unconfigurable property
1503+
try {
1504+
function(
1505+
"function (obj) {"
1506+
" var mySymbol = Symbol();"
1507+
" obj[mySymbol] = 'foo';"
1508+
" var allSymbols = Object.getOwnPropertySymbols(obj);"
1509+
" for (var sym of allSymbols) {"
1510+
" Object.defineProperty(obj, sym, {configurable: true, writable:
1511+
true});" " obj[sym] = 'bar';" " }"
1512+
"}")
1513+
.call(rt, holder);
1514+
} catch (const JSError& ex) {
1515+
// On JSC this throws, but it doesn't on Hermes
1516+
std::string exc = ex.what();
1517+
EXPECT_NE(
1518+
exc.find(
1519+
"Attempting to change configurable attribute of unconfigurable
1520+
property"),
1521+
std::string::npos);
1522+
}
1523+
1524+
EXPECT_TRUE(holder.hasNativeState(rt));
1525+
EXPECT_EQ(
1526+
std::dynamic_pointer_cast<IntState>(holder.getNativeState(rt))->value,
1527+
42);
1528+
}
15331529

15341530
TEST_P(JSITest, UTF8ExceptionTest) {
15351531
// Test that a native exception containing UTF-8 characters is correctly
@@ -1550,7 +1546,6 @@ TEST_P(JSITest, UTF8ExceptionTest) {
15501546
}
15511547
}
15521548

1553-
/* [Windows #14185
15541549
TEST_P(JSITest, UTF16ConversionTest) {
15551550
// This Runtime Decorator is used to test the conversion from UTF-8 to UTF-16
15561551
// in the default utf16 method for runtimes that do not provide their own
@@ -1658,10 +1653,8 @@ TEST_P(JSITest, CreateFromUtf16Test) {
16581653
auto cp = eval("loneSurrogate.charCodeAt(0)").getNumber();
16591654
EXPECT_EQ(cp, 55357); // 0xD83D in decimal
16601655
}
1661-
Windows] */
1656+
Windows]
16621657

1663-
/*
1664-
[Windows
16651658
TEST_P(JSITest, GetStringDataTest) {
16661659
// This Runtime Decorator is used to test the default getStringData
16671660
// implementation for VMs that do not provide their own implementation
@@ -1750,7 +1743,6 @@ TEST_P(JSITest, ObjectCreateWithPrototype) {
17501743
child = Object::create(rd, Value::null());
17511744
EXPECT_TRUE(child.getPrototype(rd).isNull());
17521745
}
1753-
Windows] */
17541746

17551747
INSTANTIATE_TEST_CASE_P(
17561748
Runtimes,

0 commit comments

Comments
 (0)