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

Unified Diff: test/cctest/test-api.cc

Issue 892393003: Update harmony ObjectProtoToString() to 2/2/2015 spec (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add tests for non-string @@toStringTag in test-api.cc Created 5 years, 11 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 | « test/cctest/cctest.h ('k') | test/mjsunit/es6/object-tostring.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 00092539d783d33e3c219ba5cac0c3ffff426cac..b8cf20dd5b0924490fdcb5b57ed484e51797e9b4 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -14002,19 +14002,58 @@ TEST(ObjectProtoToStringES6) {
} while (0)
TEST_TOSTRINGTAG(Array, Object, Object);
- TEST_TOSTRINGTAG(Object, Arguments, ~Arguments);
- TEST_TOSTRINGTAG(Object, Array, ~Array);
- TEST_TOSTRINGTAG(Object, Boolean, ~Boolean);
- TEST_TOSTRINGTAG(Object, Date, ~Date);
- TEST_TOSTRINGTAG(Object, Error, ~Error);
- TEST_TOSTRINGTAG(Object, Function, ~Function);
- TEST_TOSTRINGTAG(Object, Number, ~Number);
- TEST_TOSTRINGTAG(Object, RegExp, ~RegExp);
- TEST_TOSTRINGTAG(Object, String, ~String);
+ TEST_TOSTRINGTAG(Object, Arguments, Arguments);
+ TEST_TOSTRINGTAG(Object, Array, Array);
+ TEST_TOSTRINGTAG(Object, Boolean, Boolean);
+ TEST_TOSTRINGTAG(Object, Date, Date);
+ TEST_TOSTRINGTAG(Object, Error, Error);
+ TEST_TOSTRINGTAG(Object, Function, Function);
+ TEST_TOSTRINGTAG(Object, Number, Number);
+ TEST_TOSTRINGTAG(Object, RegExp, RegExp);
+ TEST_TOSTRINGTAG(Object, String, String);
TEST_TOSTRINGTAG(Object, Foo, Foo);
#undef TEST_TOSTRINGTAG
+ Local<v8::RegExp> valueRegExp = v8::RegExp::New(v8_str("^$"),
+ v8::RegExp::kNone);
+ Local<Value> valueNumber = v8_num(123);
+ Local<v8::Symbol> valueSymbol = v8_symbol("TestSymbol");
+ Local<v8::Function> valueFunction =
+ CompileRun("function fn() {}").As<v8::Function>();
+ Local<v8::Object> valueObject = v8::Object::New(v8::Isolate::GetCurrent());
+ Local<v8::Primitive> valueNull = v8::Null(v8::Isolate::GetCurrent());
+ Local<v8::Primitive> valueUndef = v8::Undefined(v8::Isolate::GetCurrent());
+
+#define TEST_TOSTRINGTAG(type, tagValue, expected) \
+ do { \
+ object = CompileRun("new " #type "()"); \
+ object.As<v8::Object>()->Set(toStringTag, tagValue); \
+ value = object.As<v8::Object>()->ObjectProtoToString(); \
+ CHECK(value->IsString() && \
+ value->Equals(v8_str("[object " #expected "]"))); \
+ } while (0)
+
+#define TEST_TOSTRINGTAG_TYPES(tagValue) \
+ TEST_TOSTRINGTAG(Array, tagValue, Array); \
+ TEST_TOSTRINGTAG(Object, tagValue, Object); \
+ TEST_TOSTRINGTAG(Function, tagValue, Function); \
+ TEST_TOSTRINGTAG(Date, tagValue, Date); \
+ TEST_TOSTRINGTAG(RegExp, tagValue, RegExp); \
+ TEST_TOSTRINGTAG(Error, tagValue, Error); \
+
+ // Test non-String-valued @@toStringTag
+ TEST_TOSTRINGTAG_TYPES(valueRegExp);
+ TEST_TOSTRINGTAG_TYPES(valueNumber);
+ TEST_TOSTRINGTAG_TYPES(valueSymbol);
+ TEST_TOSTRINGTAG_TYPES(valueFunction);
+ TEST_TOSTRINGTAG_TYPES(valueObject);
+ TEST_TOSTRINGTAG_TYPES(valueNull);
+ TEST_TOSTRINGTAG_TYPES(valueUndef);
+
+#undef TEST_TOSTRINGTAG
+#undef TEST_TOSTRINGTAG_TYPES
+
// @@toStringTag getter throws
Local<Value> obj = v8::Object::New(isolate);
obj.As<v8::Object>()->SetAccessor(toStringTag, ThrowingSymbolAccessorGetter);
« no previous file with comments | « test/cctest/cctest.h ('k') | test/mjsunit/es6/object-tostring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698