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 13730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13741 v8::Script::Compile(script, &origin)->Run(); | 13741 v8::Script::Compile(script, &origin)->Run(); |
13742 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 13742 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
13743 env->Global()->Get(v8::String::New("f"))); | 13743 env->Global()->Get(v8::String::New("f"))); |
13744 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 13744 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
13745 env->Global()->Get(v8::String::New("g"))); | 13745 env->Global()->Get(v8::String::New("g"))); |
13746 CHECK_EQ(0, f->GetScriptLineNumber()); | 13746 CHECK_EQ(0, f->GetScriptLineNumber()); |
13747 CHECK_EQ(2, g->GetScriptLineNumber()); | 13747 CHECK_EQ(2, g->GetScriptLineNumber()); |
13748 } | 13748 } |
13749 | 13749 |
13750 | 13750 |
| 13751 THREADED_TEST(ScriptColumnNumber) { |
| 13752 v8::HandleScope scope; |
| 13753 LocalContext env; |
| 13754 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"), |
| 13755 v8::Integer::New(3), v8::Integer::New(2)); |
| 13756 v8::Handle<v8::String> script = v8::String::New( |
| 13757 "function foo() {}\n\n function bar() {}"); |
| 13758 v8::Script::Compile(script, &origin)->Run(); |
| 13759 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 13760 env->Global()->Get(v8::String::New("foo"))); |
| 13761 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 13762 env->Global()->Get(v8::String::New("bar"))); |
| 13763 CHECK_EQ(14, foo->GetScriptColumnNumber()); |
| 13764 CHECK_EQ(17, bar->GetScriptColumnNumber()); |
| 13765 } |
| 13766 |
| 13767 |
| 13768 THREADED_TEST(FunctionGetScriptId) { |
| 13769 v8::HandleScope scope; |
| 13770 LocalContext env; |
| 13771 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"), |
| 13772 v8::Integer::New(3), v8::Integer::New(2)); |
| 13773 v8::Handle<v8::String> scriptSource = v8::String::New( |
| 13774 "function foo() {}\n\n function bar() {}"); |
| 13775 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
| 13776 script->Run(); |
| 13777 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 13778 env->Global()->Get(v8::String::New("foo"))); |
| 13779 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 13780 env->Global()->Get(v8::String::New("bar"))); |
| 13781 CHECK_EQ(script->Id(), foo->GetScriptId()); |
| 13782 CHECK_EQ(script->Id(), bar->GetScriptId()); |
| 13783 } |
| 13784 |
| 13785 |
13751 static v8::Handle<Value> GetterWhichReturns42(Local<String> name, | 13786 static v8::Handle<Value> GetterWhichReturns42(Local<String> name, |
13752 const AccessorInfo& info) { | 13787 const AccessorInfo& info) { |
13753 return v8_num(42); | 13788 return v8_num(42); |
13754 } | 13789 } |
13755 | 13790 |
13756 | 13791 |
13757 static void SetterWhichSetsYOnThisTo23(Local<String> name, | 13792 static void SetterWhichSetsYOnThisTo23(Local<String> name, |
13758 Local<Value> value, | 13793 Local<Value> value, |
13759 const AccessorInfo& info) { | 13794 const AccessorInfo& info) { |
13760 info.This()->Set(v8_str("y"), v8_num(23)); | 13795 info.This()->Set(v8_str("y"), v8_num(23)); |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15489 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 15524 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
15490 | 15525 |
15491 // TODO(1547): Make the following also return "i". | 15526 // TODO(1547): Make the following also return "i". |
15492 // Calling with environment record as base. | 15527 // Calling with environment record as base. |
15493 TestReceiver(o, context->Global(), "func()"); | 15528 TestReceiver(o, context->Global(), "func()"); |
15494 // Calling with no base. | 15529 // Calling with no base. |
15495 TestReceiver(o, context->Global(), "(1,func)()"); | 15530 TestReceiver(o, context->Global(), "(1,func)()"); |
15496 | 15531 |
15497 foreign_context.Dispose(); | 15532 foreign_context.Dispose(); |
15498 } | 15533 } |
OLD | NEW |