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

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: 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 12183 matching lines...) Expand 10 before | Expand all | Expand 10 after
12194 12194
12195 v8::TryCatch try_catch; 12195 v8::TryCatch try_catch;
12196 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); 12196 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone);
12197 CHECK(re.IsEmpty()); 12197 CHECK(re.IsEmpty());
12198 CHECK(try_catch.HasCaught()); 12198 CHECK(try_catch.HasCaught());
12199 context->Global()->Set(v8_str("ex"), try_catch.Exception()); 12199 context->Global()->Set(v8_str("ex"), try_catch.Exception());
12200 ExpectTrue("ex instanceof SyntaxError"); 12200 ExpectTrue("ex instanceof SyntaxError");
12201 } 12201 }
12202 12202
12203 12203
12204 THREADED_TEST(EQUALS) {
12205 v8::HandleScope handleScope;
12206 LocalContext localContext;
12207
12208 v8::Handle<v8::Object> globalProxy = localContext->Global();
12209 v8::Handle<Value> global = globalProxy->GetPrototype();
12210
12211 CHECK_EQ(1, global->StrictEquals(global));
Mads Ager (chromium) 2011/02/01 08:36:34 Please use true and false instead of 1 and 0.
antonm 2011/02/01 12:43:12 Sure and should have done it myself.
12212 CHECK_EQ(0, global->StrictEquals(globalProxy));
12213 CHECK_EQ(0, globalProxy->StrictEquals(global));
12214 CHECK_EQ(1, globalProxy->StrictEquals(globalProxy));
12215
12216 CHECK_EQ(1, global->Equals(global));
12217 CHECK_EQ(0, global->Equals(globalProxy));
12218 CHECK_EQ(0, globalProxy->Equals(global));
12219 CHECK_EQ(1, globalProxy->Equals(globalProxy));
12220 }
12221
12222
12204 static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property, 12223 static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
12205 const v8::AccessorInfo& info ) { 12224 const v8::AccessorInfo& info ) {
12206 return v8_str("42!"); 12225 return v8_str("42!");
12207 } 12226 }
12208 12227
12209 12228
12210 static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) { 12229 static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) {
12211 v8::Handle<v8::Array> result = v8::Array::New(); 12230 v8::Handle<v8::Array> result = v8::Array::New();
12212 result->Set(0, v8_str("universalAnswer")); 12231 result->Set(0, v8_str("universalAnswer"));
12213 return result; 12232 return result;
12214 } 12233 }
12215 12234
12216 12235
12217 TEST(NamedEnumeratorAndForIn) { 12236 TEST(NamedEnumeratorAndForIn) {
12218 v8::HandleScope handle_scope; 12237 v8::HandleScope handle_scope;
12219 LocalContext context; 12238 LocalContext context;
12220 v8::Context::Scope context_scope(context.local()); 12239 v8::Context::Scope context_scope(context.local());
12221 12240
12222 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12241 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12223 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12242 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12224 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12243 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12225 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12244 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12226 "var result = []; for (var k in o) result.push(k); result")); 12245 "var result = []; for (var k in o) result.push(k); result"));
12227 CHECK_EQ(1, result->Length()); 12246 CHECK_EQ(1, result->Length());
12228 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12247 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12229 } 12248 }
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