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 21011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21022 | 21022 |
21023 { | 21023 { |
21024 v8::HandleScope handle_scope(isolate); | 21024 v8::HandleScope handle_scope(isolate); |
21025 | 21025 |
21026 // Should work | 21026 // Should work |
21027 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 21027 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
21028 | 21028 |
21029 USE(obj); | 21029 USE(obj); |
21030 } | 21030 } |
21031 } | 21031 } |
| 21032 |
| 21033 |
| 21034 TEST(StrongModeArityCallFromApi) { |
| 21035 i::FLAG_strong_mode = true; |
| 21036 LocalContext env; |
| 21037 v8::Isolate* isolate = env->GetIsolate(); |
| 21038 v8::HandleScope scope(isolate); |
| 21039 Local<Function> fun; |
| 21040 { |
| 21041 v8::TryCatch try_catch; |
| 21042 fun = Local<Function>::Cast(CompileRun( |
| 21043 "function f(x) { 'use strong'; }" |
| 21044 "f")); |
| 21045 |
| 21046 CHECK(!try_catch.HasCaught()); |
| 21047 } |
| 21048 |
| 21049 { |
| 21050 v8::TryCatch try_catch; |
| 21051 fun->Call(v8::Undefined(isolate), 0, nullptr); |
| 21052 CHECK(try_catch.HasCaught()); |
| 21053 } |
| 21054 |
| 21055 { |
| 21056 v8::TryCatch try_catch; |
| 21057 v8::Handle<Value> args[] = {v8_num(42)}; |
| 21058 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21059 CHECK(!try_catch.HasCaught()); |
| 21060 } |
| 21061 |
| 21062 { |
| 21063 v8::TryCatch try_catch; |
| 21064 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21065 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21066 CHECK(!try_catch.HasCaught()); |
| 21067 } |
| 21068 } |
| 21069 |
| 21070 |
| 21071 TEST(StrongModeArityCallFromApi2) { |
| 21072 i::FLAG_strong_mode = true; |
| 21073 LocalContext env; |
| 21074 v8::Isolate* isolate = env->GetIsolate(); |
| 21075 v8::HandleScope scope(isolate); |
| 21076 Local<Function> fun; |
| 21077 { |
| 21078 v8::TryCatch try_catch; |
| 21079 fun = Local<Function>::Cast(CompileRun( |
| 21080 "'use strong';" |
| 21081 "function f(x) {}" |
| 21082 "f")); |
| 21083 |
| 21084 CHECK(!try_catch.HasCaught()); |
| 21085 } |
| 21086 |
| 21087 { |
| 21088 v8::TryCatch try_catch; |
| 21089 fun->Call(v8::Undefined(isolate), 0, nullptr); |
| 21090 CHECK(try_catch.HasCaught()); |
| 21091 } |
| 21092 |
| 21093 { |
| 21094 v8::TryCatch try_catch; |
| 21095 v8::Handle<Value> args[] = {v8_num(42)}; |
| 21096 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21097 CHECK(!try_catch.HasCaught()); |
| 21098 } |
| 21099 |
| 21100 { |
| 21101 v8::TryCatch try_catch; |
| 21102 v8::Handle<Value> args[] = {v8_num(42), v8_num(555)}; |
| 21103 fun->Call(v8::Undefined(isolate), arraysize(args), args); |
| 21104 CHECK(!try_catch.HasCaught()); |
| 21105 } |
| 21106 } |
OLD | NEW |