| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 9545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9556 v8::internal::Heap::CollectAllGarbage(false); | 9556 v8::internal::Heap::CollectAllGarbage(false); |
| 9557 if (GetGlobalObjectsCount() == 1) break; | 9557 if (GetGlobalObjectsCount() == 1) break; |
| 9558 } | 9558 } |
| 9559 CHECK_GE(2, gc_count); | 9559 CHECK_GE(2, gc_count); |
| 9560 CHECK_EQ(1, GetGlobalObjectsCount()); | 9560 CHECK_EQ(1, GetGlobalObjectsCount()); |
| 9561 | 9561 |
| 9562 other_context.Dispose(); | 9562 other_context.Dispose(); |
| 9563 } | 9563 } |
| 9564 | 9564 |
| 9565 | 9565 |
| 9566 TEST(ScriptOrigin) { | 9566 THREADED_TEST(ScriptOrigin) { |
| 9567 v8::HandleScope scope; | 9567 v8::HandleScope scope; |
| 9568 LocalContext env; | 9568 LocalContext env; |
| 9569 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 9569 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
| 9570 v8::Handle<v8::String> script = v8::String::New( | 9570 v8::Handle<v8::String> script = v8::String::New( |
| 9571 "function f() {}\n\nfunction g() {}"); | 9571 "function f() {}\n\nfunction g() {}"); |
| 9572 v8::Script::Compile(script, &origin)->Run(); | 9572 v8::Script::Compile(script, &origin)->Run(); |
| 9573 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 9573 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 9574 env->Global()->Get(v8::String::New("f"))); | 9574 env->Global()->Get(v8::String::New("f"))); |
| 9575 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 9575 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 9576 env->Global()->Get(v8::String::New("g"))); | 9576 env->Global()->Get(v8::String::New("g"))); |
| 9577 | 9577 |
| 9578 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); | 9578 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); |
| 9579 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_f.ResourceName())); | 9579 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_f.ResourceName())); |
| 9580 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value()); | 9580 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value()); |
| 9581 | 9581 |
| 9582 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); | 9582 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); |
| 9583 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_g.ResourceName())); | 9583 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_g.ResourceName())); |
| 9584 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value()); | 9584 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value()); |
| 9585 } | 9585 } |
| 9586 | 9586 |
| 9587 | 9587 |
| 9588 TEST(ScriptLineNumber) { | 9588 THREADED_TEST(ScriptLineNumber) { |
| 9589 v8::HandleScope scope; | 9589 v8::HandleScope scope; |
| 9590 LocalContext env; | 9590 LocalContext env; |
| 9591 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 9591 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
| 9592 v8::Handle<v8::String> script = v8::String::New( | 9592 v8::Handle<v8::String> script = v8::String::New( |
| 9593 "function f() {}\n\nfunction g() {}"); | 9593 "function f() {}\n\nfunction g() {}"); |
| 9594 v8::Script::Compile(script, &origin)->Run(); | 9594 v8::Script::Compile(script, &origin)->Run(); |
| 9595 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 9595 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 9596 env->Global()->Get(v8::String::New("f"))); | 9596 env->Global()->Get(v8::String::New("f"))); |
| 9597 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 9597 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 9598 env->Global()->Get(v8::String::New("g"))); | 9598 env->Global()->Get(v8::String::New("g"))); |
| 9599 CHECK_EQ(0, f->GetScriptLineNumber()); | 9599 CHECK_EQ(0, f->GetScriptLineNumber()); |
| 9600 CHECK_EQ(2, g->GetScriptLineNumber()); | 9600 CHECK_EQ(2, g->GetScriptLineNumber()); |
| 9601 } | 9601 } |
| OLD | NEW |