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 20992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21003 | 21003 |
21004 { | 21004 { |
21005 v8::HandleScope handle_scope(isolate); | 21005 v8::HandleScope handle_scope(isolate); |
21006 | 21006 |
21007 // Should work | 21007 // Should work |
21008 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 21008 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
21009 | 21009 |
21010 USE(obj); | 21010 USE(obj); |
21011 } | 21011 } |
21012 } | 21012 } |
| 21013 |
| 21014 |
| 21015 TEST(StrongModeArityCallFromApi) { |
| 21016 i::FLAG_strong_mode = true; |
| 21017 LocalContext env; |
| 21018 v8::Isolate* isolate = env->GetIsolate(); |
| 21019 v8::HandleScope scope(isolate); |
| 21020 Local<Function> fun; |
| 21021 { |
| 21022 v8::TryCatch try_catch; |
| 21023 fun = Local<Function>::Cast(CompileRun( |
| 21024 "function f(x) { 'use strong'; }" |
| 21025 "f")); |
| 21026 |
| 21027 CHECK(!try_catch.HasCaught()); |
| 21028 } |
| 21029 |
| 21030 { |
| 21031 v8::TryCatch try_catch; |
| 21032 fun->Call(v8::Undefined(isolate), 0, nullptr); |
| 21033 CHECK(try_catch.HasCaught()); |
| 21034 } |
| 21035 |
| 21036 { |
| 21037 v8::TryCatch try_catch; |
| 21038 v8::Handle<Value> args[] = {v8_num(42)}; |
| 21039 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21040 CHECK(!try_catch.HasCaught()); |
| 21041 } |
| 21042 |
| 21043 { |
| 21044 v8::TryCatch try_catch; |
| 21045 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21046 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21047 CHECK(!try_catch.HasCaught()); |
| 21048 } |
| 21049 } |
| 21050 |
| 21051 |
| 21052 TEST(StrongModeArityCallFromApi2) { |
| 21053 i::FLAG_strong_mode = true; |
| 21054 LocalContext env; |
| 21055 v8::Isolate* isolate = env->GetIsolate(); |
| 21056 v8::HandleScope scope(isolate); |
| 21057 Local<Function> fun; |
| 21058 { |
| 21059 v8::TryCatch try_catch; |
| 21060 fun = Local<Function>::Cast(CompileRun( |
| 21061 "'use strong';" |
| 21062 "function f(x) {}" |
| 21063 "f")); |
| 21064 |
| 21065 CHECK(!try_catch.HasCaught()); |
| 21066 } |
| 21067 |
| 21068 { |
| 21069 v8::TryCatch try_catch; |
| 21070 fun->Call(v8::Undefined(isolate), 0, nullptr); |
| 21071 CHECK(try_catch.HasCaught()); |
| 21072 } |
| 21073 |
| 21074 { |
| 21075 v8::TryCatch try_catch; |
| 21076 v8::Handle<Value> args[] = {v8_num(42)}; |
| 21077 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21078 CHECK(!try_catch.HasCaught()); |
| 21079 } |
| 21080 |
| 21081 { |
| 21082 v8::TryCatch try_catch; |
| 21083 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21084 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21085 CHECK(!try_catch.HasCaught()); |
| 21086 } |
| 21087 } |
OLD | NEW |