OLD | NEW |
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 Loading... |
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 10388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14609 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); | 14609 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); |
14610 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); | 14610 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); |
14611 obj->Set(v8_num(2), v8_str("foobar")); | 14611 obj->Set(v8_num(2), v8_str("foobar")); |
14612 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); | 14612 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); |
14613 | 14613 |
14614 // Test non-smi case. | 14614 // Test non-smi case. |
14615 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); | 14615 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); |
14616 obj->Set(v8_str("2000000000"), v8_str("foobar")); | 14616 obj->Set(v8_str("2000000000"), v8_str("foobar")); |
14617 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); | 14617 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); |
14618 } | 14618 } |
OLD | NEW |