OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 17739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17750 script->Run(); | 17750 script->Run(); |
17751 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 17751 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
17752 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); | 17752 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
17753 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 17753 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
17754 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); | 17754 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); |
17755 CHECK_EQ(script->GetId(), foo->ScriptId()); | 17755 CHECK_EQ(script->GetId(), foo->ScriptId()); |
17756 CHECK_EQ(script->GetId(), bar->ScriptId()); | 17756 CHECK_EQ(script->GetId(), bar->ScriptId()); |
17757 } | 17757 } |
17758 | 17758 |
17759 | 17759 |
17760 THREADED_TEST(FunctionGetBoundFunction) { | |
17761 LocalContext env; | |
17762 v8::HandleScope scope(env->GetIsolate()); | |
17763 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8( | |
17764 env->GetIsolate(), "test")); | |
yurys
2013/12/12 12:49:27
style: wrong indentation
Alexandra Mikhaylova
2013/12/12 15:53:02
Done.
| |
17765 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | |
17766 env->GetIsolate(), | |
17767 "function f () {}\n" | |
17768 "var g = f.bind();\n"); | |
17769 v8::Script::Compile(script, &origin)->Run(); | |
17770 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | |
17771 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | |
17772 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | |
17773 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | |
17774 CHECK_EQ(*v8::String::Utf8Value(f->GetName()), | |
17775 *v8::String::Utf8Value(g->GetBoundFunction()->GetName())); | |
17776 CHECK_EQ(f->GetScriptLineNumber(), | |
17777 g->GetBoundFunction()->GetScriptLineNumber()); | |
17778 CHECK_EQ(f->GetScriptColumnNumber(), | |
17779 g->GetBoundFunction()->GetScriptColumnNumber()); | |
17780 } | |
17781 | |
17782 | |
17760 static void GetterWhichReturns42( | 17783 static void GetterWhichReturns42( |
17761 Local<String> name, | 17784 Local<String> name, |
17762 const v8::PropertyCallbackInfo<v8::Value>& info) { | 17785 const v8::PropertyCallbackInfo<v8::Value>& info) { |
17763 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 17786 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
17764 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 17787 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
17765 info.GetReturnValue().Set(v8_num(42)); | 17788 info.GetReturnValue().Set(v8_num(42)); |
17766 } | 17789 } |
17767 | 17790 |
17768 | 17791 |
17769 static void SetterWhichSetsYOnThisTo23( | 17792 static void SetterWhichSetsYOnThisTo23( |
(...skipping 3102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20872 } | 20895 } |
20873 for (int i = 0; i < runs; i++) { | 20896 for (int i = 0; i < runs; i++) { |
20874 Local<String> expected; | 20897 Local<String> expected; |
20875 if (i != 0) { | 20898 if (i != 0) { |
20876 CHECK_EQ(v8_str("escape value"), values[i]); | 20899 CHECK_EQ(v8_str("escape value"), values[i]); |
20877 } else { | 20900 } else { |
20878 CHECK(values[i].IsEmpty()); | 20901 CHECK(values[i].IsEmpty()); |
20879 } | 20902 } |
20880 } | 20903 } |
20881 } | 20904 } |
OLD | NEW |