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 17818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17829 script->Run(); | 17829 script->Run(); |
17830 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 17830 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
17831 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); | 17831 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
17832 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 17832 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
17833 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); | 17833 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); |
17834 CHECK_EQ(script->GetId(), foo->ScriptId()); | 17834 CHECK_EQ(script->GetId(), foo->ScriptId()); |
17835 CHECK_EQ(script->GetId(), bar->ScriptId()); | 17835 CHECK_EQ(script->GetId(), bar->ScriptId()); |
17836 } | 17836 } |
17837 | 17837 |
17838 | 17838 |
17839 THREADED_TEST(FunctionGetBoundFunction) { | |
17840 LocalContext env; | |
17841 v8::HandleScope scope(env->GetIsolate()); | |
17842 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8( | |
17843 env->GetIsolate(), "test")); | |
17844 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | |
17845 env->GetIsolate(), | |
17846 "function f () {}\n" | |
17847 "var g = f.bind();\n"); | |
17848 v8::Script::Compile(script, &origin)->Run(); | |
17849 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | |
17850 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | |
17851 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | |
17852 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | |
17853 CHECK(!g->GetBoundFunction()->IsUndefined()); | |
yurys
2013/12/12 20:20:50
CHECK(g->GetBoundFunction()->IsFunction())
Alexandra Mikhaylova
2013/12/18 10:00:28
Done.
| |
17854 CHECK_EQ(*v8::String::Utf8Value(f->GetName()), | |
yurys
2013/12/12 20:20:50
CHECK_EQ should work well for Handles, you don't n
Alexandra Mikhaylova
2013/12/18 10:00:28
Done.
| |
17855 *v8::String::Utf8Value( | |
17856 Local<v8::Function>::Cast(g->GetBoundFunction())->GetName())); | |
yurys
2013/12/12 20:20:50
It may make sense to extract Local<v8::Function>::
Alexandra Mikhaylova
2013/12/18 10:00:28
Done.
| |
17857 CHECK_EQ(f->GetScriptLineNumber(), | |
17858 Local<v8::Function>::Cast( | |
17859 g->GetBoundFunction())->GetScriptLineNumber()); | |
17860 CHECK_EQ(f->GetScriptColumnNumber(), | |
17861 Local<v8::Function>::Cast( | |
17862 g->GetBoundFunction())->GetScriptColumnNumber()); | |
17863 } | |
17864 | |
17865 | |
17839 static void GetterWhichReturns42( | 17866 static void GetterWhichReturns42( |
17840 Local<String> name, | 17867 Local<String> name, |
17841 const v8::PropertyCallbackInfo<v8::Value>& info) { | 17868 const v8::PropertyCallbackInfo<v8::Value>& info) { |
17842 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 17869 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
17843 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 17870 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
17844 info.GetReturnValue().Set(v8_num(42)); | 17871 info.GetReturnValue().Set(v8_num(42)); |
17845 } | 17872 } |
17846 | 17873 |
17847 | 17874 |
17848 static void SetterWhichSetsYOnThisTo23( | 17875 static void SetterWhichSetsYOnThisTo23( |
(...skipping 3101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20950 } | 20977 } |
20951 for (int i = 0; i < runs; i++) { | 20978 for (int i = 0; i < runs; i++) { |
20952 Local<String> expected; | 20979 Local<String> expected; |
20953 if (i != 0) { | 20980 if (i != 0) { |
20954 CHECK_EQ(v8_str("escape value"), values[i]); | 20981 CHECK_EQ(v8_str("escape value"), values[i]); |
20955 } else { | 20982 } else { |
20956 CHECK(values[i].IsEmpty()); | 20983 CHECK(values[i].IsEmpty()); |
20957 } | 20984 } |
20958 } | 20985 } |
20959 } | 20986 } |
OLD | NEW |