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

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

Issue 7245001: Ported patch from revision 3839 to trunk. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/version.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 4177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4188 v8::ExtensionConfiguration extensions(1, extension_names); 4188 v8::ExtensionConfiguration extensions(1, extension_names);
4189 v8::Handle<Context> context = Context::New(&extensions); 4189 v8::Handle<Context> context = Context::New(&extensions);
4190 Context::Scope lock(context); 4190 Context::Scope lock(context);
4191 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); 4191 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run();
4192 CHECK_EQ(result, v8::Integer::New(42)); 4192 CHECK_EQ(result, v8::Integer::New(42));
4193 } 4193 }
4194 4194
4195 4195
4196 THREADED_TEST(NativeFunctionDeclarationError) { 4196 THREADED_TEST(NativeFunctionDeclarationError) {
4197 v8::HandleScope handle_scope; 4197 v8::HandleScope handle_scope;
4198 const char* name = "nativedecl"; 4198 const char* name = "nativedeclerr";
4199 // Syntax error in extension code. 4199 // Syntax error in extension code.
4200 v8::RegisterExtension(new NativeFunctionExtension(name, 4200 v8::RegisterExtension(new NativeFunctionExtension(name,
4201 "native\nfunction foo();")); 4201 "native\nfunction foo();"));
4202 const char* extension_names[] = { name }; 4202 const char* extension_names[] = { name };
4203 v8::ExtensionConfiguration extensions(1, extension_names); 4203 v8::ExtensionConfiguration extensions(1, extension_names);
4204 v8::Handle<Context> context = Context::New(&extensions); 4204 v8::Handle<Context> context = Context::New(&extensions);
4205 ASSERT(context.IsEmpty()); 4205 ASSERT(context.IsEmpty());
4206 } 4206 }
4207 4207
4208 THREADED_TEST(NativeFunctionDeclarationErrorEscape) { 4208 THREADED_TEST(NativeFunctionDeclarationErrorEscape) {
4209 v8::HandleScope handle_scope; 4209 v8::HandleScope handle_scope;
4210 const char* name = "nativedecl"; 4210 const char* name = "nativedeclerresc";
4211 // Syntax error in extension code - escape code in "native" means that 4211 // Syntax error in extension code - escape code in "native" means that
4212 // it's not treated as a keyword. 4212 // it's not treated as a keyword.
4213 v8::RegisterExtension(new NativeFunctionExtension( 4213 v8::RegisterExtension(new NativeFunctionExtension(
4214 name, 4214 name,
4215 "nativ\\u0065 function foo();")); 4215 "nativ\\u0065 function foo();"));
4216 const char* extension_names[] = { name }; 4216 const char* extension_names[] = { name };
4217 v8::ExtensionConfiguration extensions(1, extension_names); 4217 v8::ExtensionConfiguration extensions(1, extension_names);
4218 v8::Handle<Context> context = Context::New(&extensions); 4218 v8::Handle<Context> context = Context::New(&extensions);
4219 ASSERT(context.IsEmpty()); 4219 ASSERT(context.IsEmpty());
4220 } 4220 }
(...skipping 10338 matching lines...) Expand 10 before | Expand all | Expand 10 after
14559 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); 14559 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1")));
14560 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); 14560 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly);
14561 obj->Set(v8_num(2), v8_str("foobar")); 14561 obj->Set(v8_num(2), v8_str("foobar"));
14562 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); 14562 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2)));
14563 14563
14564 // Test non-smi case. 14564 // Test non-smi case.
14565 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); 14565 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly);
14566 obj->Set(v8_str("2000000000"), v8_str("foobar")); 14566 obj->Set(v8_str("2000000000"), v8_str("foobar"));
14567 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); 14567 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000")));
14568 } 14568 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698