Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13482 CHECK(value->IsString() && value->Equals(v8_str("[object MyClass]"))); | 13482 CHECK(value->IsString() && value->Equals(v8_str("[object MyClass]"))); |
| 13483 | 13483 |
| 13484 // Check global | 13484 // Check global |
| 13485 value = context->Global()->ObjectProtoToString(); | 13485 value = context->Global()->ObjectProtoToString(); |
| 13486 CHECK(value->IsString() && value->Equals(v8_str("[object global]"))); | 13486 CHECK(value->IsString() && value->Equals(v8_str("[object global]"))); |
| 13487 | 13487 |
| 13488 // Check ordinary object | 13488 // Check ordinary object |
| 13489 Local<Value> object = v8_compile("new Object()")->Run(); | 13489 Local<Value> object = v8_compile("new Object()")->Run(); |
| 13490 value = object.As<v8::Object>()->ObjectProtoToString(); | 13490 value = object.As<v8::Object>()->ObjectProtoToString(); |
| 13491 CHECK(value->IsString() && value->Equals(v8_str("[object Object]"))); | 13491 CHECK(value->IsString() && value->Equals(v8_str("[object Object]"))); |
| 13492 | |
| 13493 // Check that ES6 semantics using @@toStringTag work | |
| 13494 i::FLAG_harmony_tostring = true; | |
| 13495 Local<v8::Symbol> toStringTag = v8::Symbol::GetToStringTag(isolate); | |
| 13496 | |
| 13497 object = v8_compile("new Object()")->Run(); | |
| 13498 object.As<v8::Object>()->Set(toStringTag, v8_str("Foo")); | |
| 13499 value = object.As<v8::Object>()->ObjectProtoToString(); | |
| 13500 CHECK(value->IsString() && value->Equals(v8_str("[object Foo]"))); | |
| 13501 | |
| 13502 object = v8_compile("new Object()")->Run(); | |
| 13503 object.As<v8::Object>()->Set(toStringTag, v8_str("Array")); | |
| 13504 value = object.As<v8::Object>()->ObjectProtoToString(); | |
| 13505 CHECK(value->IsString() && value->Equals(v8_str("[object ~Array]"))); | |
|
Dmitry Lomov (no reviews)
2014/10/18 15:16:48
Add a test that creates an object with a getter fo
| |
| 13492 } | 13506 } |
| 13493 | 13507 |
| 13494 | 13508 |
| 13495 THREADED_TEST(ObjectGetConstructorName) { | 13509 THREADED_TEST(ObjectGetConstructorName) { |
| 13496 LocalContext context; | 13510 LocalContext context; |
| 13497 v8::HandleScope scope(context->GetIsolate()); | 13511 v8::HandleScope scope(context->GetIsolate()); |
| 13498 v8_compile("function Parent() {};" | 13512 v8_compile("function Parent() {};" |
| 13499 "function Child() {};" | 13513 "function Child() {};" |
| 13500 "Child.prototype = new Parent();" | 13514 "Child.prototype = new Parent();" |
| 13501 "var outer = { inner: function() { } };" | 13515 "var outer = { inner: function() { } };" |
| (...skipping 10332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 23834 char chunk2[] = | 23848 char chunk2[] = |
| 23835 "XXr = 13;\n" | 23849 "XXr = 13;\n" |
| 23836 " return foob\xeb\x91\x80\xeb\x91\x80r;\n" | 23850 " return foob\xeb\x91\x80\xeb\x91\x80r;\n" |
| 23837 "}\n"; | 23851 "}\n"; |
| 23838 chunk1[strlen(chunk1) - 1] = reference[0]; | 23852 chunk1[strlen(chunk1) - 1] = reference[0]; |
| 23839 chunk2[0] = reference[1]; | 23853 chunk2[0] = reference[1]; |
| 23840 chunk2[1] = reference[2]; | 23854 chunk2[1] = reference[2]; |
| 23841 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; | 23855 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; |
| 23842 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); | 23856 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); |
| 23843 } | 23857 } |
| OLD | NEW |