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 20575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20586 Local<Object> data2 = v8::Object::New(); | 20586 Local<Object> data2 = v8::Object::New(); |
20587 function_new_expected_env = data2; | 20587 function_new_expected_env = data2; |
20588 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 20588 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
20589 CHECK(!func2->IsNull()); | 20589 CHECK(!func2->IsNull()); |
20590 CHECK_NE(func, func2); | 20590 CHECK_NE(func, func2); |
20591 env->Global()->Set(v8_str("func2"), func2); | 20591 env->Global()->Set(v8_str("func2"), func2); |
20592 Local<Value> result2 = CompileRun("func2();"); | 20592 Local<Value> result2 = CompileRun("func2();"); |
20593 CHECK_EQ(v8::Integer::New(17, isolate), result2); | 20593 CHECK_EQ(v8::Integer::New(17, isolate), result2); |
20594 } | 20594 } |
20595 | 20595 |
| 20596 |
| 20597 TEST(EscapeableHandleScope) { |
| 20598 HandleScope outer_scope(CcTest::isolate()); |
| 20599 LocalContext context; |
| 20600 const int runs = 10; |
| 20601 Local<String> values[runs]; |
| 20602 for (int i = 0; i < runs; i++) { |
| 20603 v8::EscapableHandleScope inner_scope(CcTest::isolate()); |
| 20604 Local<String> value; |
| 20605 if (i != 0) value = v8_str("escape value"); |
| 20606 values[i] = inner_scope.Escape(value); |
| 20607 } |
| 20608 for (int i = 0; i < runs; i++) { |
| 20609 Local<String> expected; |
| 20610 if (i != 0) { |
| 20611 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20612 } else { |
| 20613 CHECK(values[i].IsEmpty()); |
| 20614 } |
| 20615 } |
| 20616 } |
OLD | NEW |