Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(686)

Unified Diff: test/cctest/interpreter/test-interpreter-intrinsics.cc

Issue 2034493002: [Interpreter] Add intrinsics for Is<Type> calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add non-smi int to test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/interpreter-intrinsics.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-interpreter-intrinsics.cc
diff --git a/test/cctest/interpreter/test-interpreter-intrinsics.cc b/test/cctest/interpreter/test-interpreter-intrinsics.cc
index cfbfc462c8187b8b4511bae48619724f0ae840f2..b9dffcc70a92891754d58fec08c5ed559bff8651 100644
--- a/test/cctest/interpreter/test-interpreter-intrinsics.cc
+++ b/test/cctest/interpreter/test-interpreter-intrinsics.cc
@@ -91,6 +91,105 @@ TEST(IsArray) {
CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
}
+TEST(IsJSProxy) {
+ HandleAndZoneScope handles;
+
+ InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
+ Runtime::kInlineIsJSProxy);
+ Factory* factory = handles.main_isolate()->factory();
+
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("new Date()")));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("(function() {})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("([1])")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("'string'")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
+ CHECK_EQ(*factory->true_value(),
+ *helper.Invoke(helper.NewObject("new Proxy({},{})")));
+}
+
+TEST(IsRegExp) {
+ HandleAndZoneScope handles;
+
+ InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
+ Runtime::kInlineIsRegExp);
+ Factory* factory = handles.main_isolate()->factory();
+
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("new Date()")));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("(function() {})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("([1])")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
+ CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("(/x/)")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("'string'")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
+}
+
+TEST(IsTypedArray) {
+ HandleAndZoneScope handles;
+
+ InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
+ Runtime::kInlineIsTypedArray);
+ Factory* factory = handles.main_isolate()->factory();
+
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("new Date()")));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("(function() {})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("([1])")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("'string'")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
+
+ CHECK_EQ(
+ *factory->true_value(),
+ *helper.Invoke(helper.NewObject("new Uint8Array(new ArrayBuffer(1));")));
+ CHECK_EQ(
+ *factory->true_value(),
+ *helper.Invoke(helper.NewObject("new Uint16Array(new ArrayBuffer(2));")));
+ CHECK_EQ(
+ *factory->true_value(),
+ *helper.Invoke(helper.NewObject("new Int32Array(new ArrayBuffer(4));")));
+}
+
+TEST(IsSmi) {
+ HandleAndZoneScope handles;
+
+ InvokeIntrinsicHelper helper(handles.main_isolate(), handles.main_zone(),
+ Runtime::kInlineIsSmi);
+ Factory* factory = handles.main_isolate()->factory();
+
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("new Date()")));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("(function() {})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("([1])")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("'string'")));
+ CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42.2")));
+ CHECK_EQ(*factory->false_value(),
+ *helper.Invoke(helper.NewObject("4294967297")));
+ CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("42")));
+}
+
TEST(Call) {
HandleAndZoneScope handles;
Isolate* isolate = handles.main_isolate();
« no previous file with comments | « src/interpreter/interpreter-intrinsics.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698