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

Side by Side Diff: test/cctest/test-api.cc

Issue 6287018: Compare JSObjects by identity immediately. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing Mads' concerns Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 12195 matching lines...) Expand 10 before | Expand all | Expand 10 after
12206 12206
12207 v8::TryCatch try_catch; 12207 v8::TryCatch try_catch;
12208 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); 12208 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone);
12209 CHECK(re.IsEmpty()); 12209 CHECK(re.IsEmpty());
12210 CHECK(try_catch.HasCaught()); 12210 CHECK(try_catch.HasCaught());
12211 context->Global()->Set(v8_str("ex"), try_catch.Exception()); 12211 context->Global()->Set(v8_str("ex"), try_catch.Exception());
12212 ExpectTrue("ex instanceof SyntaxError"); 12212 ExpectTrue("ex instanceof SyntaxError");
12213 } 12213 }
12214 12214
12215 12215
12216 THREADED_TEST(Equals) {
12217 v8::HandleScope handleScope;
12218 LocalContext localContext;
12219
12220 v8::Handle<v8::Object> globalProxy = localContext->Global();
12221 v8::Handle<Value> global = globalProxy->GetPrototype();
12222
12223 CHECK(global->StrictEquals(global));
12224 CHECK(!global->StrictEquals(globalProxy));
12225 CHECK(!globalProxy->StrictEquals(global));
12226 CHECK(globalProxy->StrictEquals(globalProxy));
12227
12228 CHECK(global->Equals(global));
12229 CHECK(!global->Equals(globalProxy));
12230 CHECK(!globalProxy->Equals(global));
12231 CHECK(globalProxy->Equals(globalProxy));
12232 }
12233
12234
12216 static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property, 12235 static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
12217 const v8::AccessorInfo& info ) { 12236 const v8::AccessorInfo& info ) {
12218 return v8_str("42!"); 12237 return v8_str("42!");
12219 } 12238 }
12220 12239
12221 12240
12222 static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) { 12241 static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) {
12223 v8::Handle<v8::Array> result = v8::Array::New(); 12242 v8::Handle<v8::Array> result = v8::Array::New();
12224 result->Set(0, v8_str("universalAnswer")); 12243 result->Set(0, v8_str("universalAnswer"));
12225 return result; 12244 return result;
12226 } 12245 }
12227 12246
12228 12247
12229 TEST(NamedEnumeratorAndForIn) { 12248 TEST(NamedEnumeratorAndForIn) {
12230 v8::HandleScope handle_scope; 12249 v8::HandleScope handle_scope;
12231 LocalContext context; 12250 LocalContext context;
12232 v8::Context::Scope context_scope(context.local()); 12251 v8::Context::Scope context_scope(context.local());
12233 12252
12234 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12253 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12235 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12254 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12236 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12255 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12237 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12256 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12238 "var result = []; for (var k in o) result.push(k); result")); 12257 "var result = []; for (var k in o) result.push(k); result"));
12239 CHECK_EQ(1, result->Length()); 12258 CHECK_EQ(1, result->Length());
12240 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12259 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12241 } 12260 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698