| 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 4590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4601 // must work for non-function receivers. | 4601 // must work for non-function receivers. |
| 4602 const char* apply_99 = "Function.prototype.call.apply(obj, [this, 99])"; | 4602 const char* apply_99 = "Function.prototype.call.apply(obj, [this, 99])"; |
| 4603 value = Script::Compile(v8_str(apply_99))->Run(); | 4603 value = Script::Compile(v8_str(apply_99))->Run(); |
| 4604 CHECK(!try_catch.HasCaught()); | 4604 CHECK(!try_catch.HasCaught()); |
| 4605 CHECK_EQ(99, value->Int32Value()); | 4605 CHECK_EQ(99, value->Int32Value()); |
| 4606 | 4606 |
| 4607 const char* call_17 = "Function.prototype.call.call(obj, this, 17)"; | 4607 const char* call_17 = "Function.prototype.call.call(obj, this, 17)"; |
| 4608 value = Script::Compile(v8_str(call_17))->Run(); | 4608 value = Script::Compile(v8_str(call_17))->Run(); |
| 4609 CHECK(!try_catch.HasCaught()); | 4609 CHECK(!try_catch.HasCaught()); |
| 4610 CHECK_EQ(17, value->Int32Value()); | 4610 CHECK_EQ(17, value->Int32Value()); |
| 4611 | |
| 4612 // Try something that will cause an exception: Call the object as a | |
| 4613 // constructor. This should be the last test. | |
| 4614 value = Script::Compile(v8_str("new obj(42)"))->Run(); | |
| 4615 CHECK(try_catch.HasCaught()); | |
| 4616 } | 4611 } |
| 4617 | 4612 |
| 4618 | 4613 |
| 4619 static int CountHandles() { | 4614 static int CountHandles() { |
| 4620 return v8::HandleScope::NumberOfHandles(); | 4615 return v8::HandleScope::NumberOfHandles(); |
| 4621 } | 4616 } |
| 4622 | 4617 |
| 4623 | 4618 |
| 4624 static int Recurse(int depth, int iterations) { | 4619 static int Recurse(int depth, int iterations) { |
| 4625 v8::HandleScope scope; | 4620 v8::HandleScope scope; |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6180 // Check without 'eval' or 'with'. | 6175 // Check without 'eval' or 'with'. |
| 6181 v8::Handle<v8::Value> res = | 6176 v8::Handle<v8::Value> res = |
| 6182 CompileRun("function f() { x = 42; return x; }; f()"); | 6177 CompileRun("function f() { x = 42; return x; }; f()"); |
| 6183 // Check with 'eval'. | 6178 // Check with 'eval'. |
| 6184 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); | 6179 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); |
| 6185 CHECK_EQ(v8::Integer::New(42), res); | 6180 CHECK_EQ(v8::Integer::New(42), res); |
| 6186 // Check with 'with'. | 6181 // Check with 'with'. |
| 6187 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); | 6182 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); |
| 6188 CHECK_EQ(v8::Integer::New(42), res); | 6183 CHECK_EQ(v8::Integer::New(42), res); |
| 6189 } | 6184 } |
| OLD | NEW |