OLD | NEW |
---|---|
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 4539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4550 // must work for non-function receivers. | 4550 // must work for non-function receivers. |
4551 const char* apply_99 = "Function.prototype.call.apply(obj, [this, 99])"; | 4551 const char* apply_99 = "Function.prototype.call.apply(obj, [this, 99])"; |
4552 value = Script::Compile(v8_str(apply_99))->Run(); | 4552 value = Script::Compile(v8_str(apply_99))->Run(); |
4553 CHECK(!try_catch.HasCaught()); | 4553 CHECK(!try_catch.HasCaught()); |
4554 CHECK_EQ(99, value->Int32Value()); | 4554 CHECK_EQ(99, value->Int32Value()); |
4555 | 4555 |
4556 const char* call_17 = "Function.prototype.call.call(obj, this, 17)"; | 4556 const char* call_17 = "Function.prototype.call.call(obj, this, 17)"; |
4557 value = Script::Compile(v8_str(call_17))->Run(); | 4557 value = Script::Compile(v8_str(call_17))->Run(); |
4558 CHECK(!try_catch.HasCaught()); | 4558 CHECK(!try_catch.HasCaught()); |
4559 CHECK_EQ(17, value->Int32Value()); | 4559 CHECK_EQ(17, value->Int32Value()); |
4560 | |
4561 // Try something that will cause an exception: Call the object as a | |
Mads Ager (chromium)
2009/04/28 10:50:15
Please add a test case for the intended behavior o
Feng Qian
2009/04/30 23:26:15
This needs to be tested by a layout test. V8 treat
| |
4562 // constructor. This should be the last test. | |
4563 value = Script::Compile(v8_str("new obj(42)"))->Run(); | |
4564 CHECK(try_catch.HasCaught()); | |
4565 } | 4560 } |
4566 | 4561 |
4567 | 4562 |
4568 static int CountHandles() { | 4563 static int CountHandles() { |
4569 return v8::HandleScope::NumberOfHandles(); | 4564 return v8::HandleScope::NumberOfHandles(); |
4570 } | 4565 } |
4571 | 4566 |
4572 | 4567 |
4573 static int Recurse(int depth, int iterations) { | 4568 static int Recurse(int depth, int iterations) { |
4574 v8::HandleScope scope; | 4569 v8::HandleScope scope; |
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6129 // Check without 'eval' or 'with'. | 6124 // Check without 'eval' or 'with'. |
6130 v8::Handle<v8::Value> res = | 6125 v8::Handle<v8::Value> res = |
6131 CompileRun("function f() { x = 42; return x; }; f()"); | 6126 CompileRun("function f() { x = 42; return x; }; f()"); |
6132 // Check with 'eval'. | 6127 // Check with 'eval'. |
6133 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); | 6128 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); |
6134 CHECK_EQ(v8::Integer::New(42), res); | 6129 CHECK_EQ(v8::Integer::New(42), res); |
6135 // Check with 'with'. | 6130 // Check with 'with'. |
6136 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); | 6131 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); |
6137 CHECK_EQ(v8::Integer::New(42), res); | 6132 CHECK_EQ(v8::Integer::New(42), res); |
6138 } | 6133 } |
OLD | NEW |