Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: test/cctest/test-api.cc

Issue 848173002: Remove support for signatures with arguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 CHECK_EQ(signature_expected_receiver, args.Holder()); 110 CHECK_EQ(signature_expected_receiver, args.Holder());
111 CHECK_EQ(signature_expected_receiver, args.This()); 111 CHECK_EQ(signature_expected_receiver, args.This());
112 v8::Handle<v8::Array> result = 112 v8::Handle<v8::Array> result =
113 v8::Array::New(args.GetIsolate(), args.Length()); 113 v8::Array::New(args.GetIsolate(), args.Length());
114 for (int i = 0; i < args.Length(); i++) 114 for (int i = 0; i < args.Length(); i++)
115 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]); 115 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]);
116 args.GetReturnValue().Set(result); 116 args.GetReturnValue().Set(result);
117 } 117 }
118 118
119 119
120 static void SignatureCallback(
121 const v8::FunctionCallbackInfo<v8::Value>& args) {
122 ApiTestFuzzer::Fuzz();
123 v8::Handle<v8::Array> result =
124 v8::Array::New(args.GetIsolate(), args.Length());
125 for (int i = 0; i < args.Length(); i++) {
126 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]);
127 }
128 args.GetReturnValue().Set(result);
129 }
130
131
132 // Tests that call v8::V8::Dispose() cannot be threaded. 120 // Tests that call v8::V8::Dispose() cannot be threaded.
133 UNINITIALIZED_TEST(InitializeAndDisposeOnce) { 121 UNINITIALIZED_TEST(InitializeAndDisposeOnce) {
134 CHECK(v8::V8::Initialize()); 122 CHECK(v8::V8::Initialize());
135 CHECK(v8::V8::Dispose()); 123 CHECK(v8::V8::Dispose());
136 } 124 }
137 125
138 126
139 // Tests that call v8::V8::Dispose() cannot be threaded. 127 // Tests that call v8::V8::Dispose() cannot be threaded.
140 UNINITIALIZED_TEST(InitializeAndDisposeMultiple) { 128 UNINITIALIZED_TEST(InitializeAndDisposeMultiple) {
141 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); 129 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (i >= bad_signature_start_offset) test_object = Local<Value>(); 264 if (i >= bad_signature_start_offset) test_object = Local<Value>();
277 TestSignature("test_object.prop_sig();", test_object, isolate); 265 TestSignature("test_object.prop_sig();", test_object, isolate);
278 TestSignature("test_object.accessor_sig;", test_object, isolate); 266 TestSignature("test_object.accessor_sig;", test_object, isolate);
279 TestSignature("test_object[accessor_sig_key];", test_object, isolate); 267 TestSignature("test_object[accessor_sig_key];", test_object, isolate);
280 TestSignature("test_object.accessor_sig = 1;", test_object, isolate); 268 TestSignature("test_object.accessor_sig = 1;", test_object, isolate);
281 TestSignature("test_object[accessor_sig_key] = 1;", test_object, isolate); 269 TestSignature("test_object[accessor_sig_key] = 1;", test_object, isolate);
282 } 270 }
283 } 271 }
284 272
285 273
286 THREADED_TEST(ArgumentSignature) {
287 LocalContext env;
288 v8::Isolate* isolate = env->GetIsolate();
289 v8::HandleScope scope(isolate);
290 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(isolate);
291 cons->SetClassName(v8_str("Cons"));
292 v8::Handle<v8::Signature> sig = v8::Signature::New(
293 isolate, v8::Handle<v8::FunctionTemplate>(), 1, &cons);
294 v8::Handle<v8::FunctionTemplate> fun =
295 v8::FunctionTemplate::New(isolate,
296 SignatureCallback,
297 v8::Handle<Value>(),
298 sig);
299 env->Global()->Set(v8_str("Cons"), cons->GetFunction());
300 env->Global()->Set(v8_str("Fun1"), fun->GetFunction());
301
302 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';");
303 CHECK(value1->IsTrue());
304
305 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';");
306 CHECK(value2->IsTrue());
307
308 v8::Handle<Value> value3 = CompileRun("Fun1() == '';");
309 CHECK(value3->IsTrue());
310
311 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(isolate);
312 cons1->SetClassName(v8_str("Cons1"));
313 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(isolate);
314 cons2->SetClassName(v8_str("Cons2"));
315 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(isolate);
316 cons3->SetClassName(v8_str("Cons3"));
317
318 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 };
319 v8::Handle<v8::Signature> wsig = v8::Signature::New(
320 isolate, v8::Handle<v8::FunctionTemplate>(), 3, args);
321 v8::Handle<v8::FunctionTemplate> fun2 =
322 v8::FunctionTemplate::New(isolate,
323 SignatureCallback,
324 v8::Handle<Value>(),
325 wsig);
326
327 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction());
328 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction());
329 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction());
330 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction());
331 v8::Handle<Value> value4 = CompileRun(
332 "Fun2(new Cons1(), new Cons2(), new Cons3()) =="
333 "'[object Cons1],[object Cons2],[object Cons3]'");
334 CHECK(value4->IsTrue());
335
336 v8::Handle<Value> value5 = CompileRun(
337 "Fun2(new Cons1(), new Cons2(), 5) == '[object Cons1],[object Cons2],'");
338 CHECK(value5->IsTrue());
339
340 v8::Handle<Value> value6 = CompileRun(
341 "Fun2(new Cons3(), new Cons2(), new Cons1()) == ',[object Cons2],'");
342 CHECK(value6->IsTrue());
343
344 v8::Handle<Value> value7 = CompileRun(
345 "Fun2(new Cons1(), new Cons2(), new Cons3(), 'd') == "
346 "'[object Cons1],[object Cons2],[object Cons3],d';");
347 CHECK(value7->IsTrue());
348
349 v8::Handle<Value> value8 = CompileRun(
350 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'");
351 CHECK(value8->IsTrue());
352 }
353
354
355 THREADED_TEST(HulIgennem) { 274 THREADED_TEST(HulIgennem) {
356 LocalContext env; 275 LocalContext env;
357 v8::Isolate* isolate = env->GetIsolate(); 276 v8::Isolate* isolate = env->GetIsolate();
358 v8::HandleScope scope(isolate); 277 v8::HandleScope scope(isolate);
359 v8::Handle<v8::Primitive> undef = v8::Undefined(isolate); 278 v8::Handle<v8::Primitive> undef = v8::Undefined(isolate);
360 Local<String> undef_str = undef->ToString(isolate); 279 Local<String> undef_str = undef->ToString(isolate);
361 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1); 280 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1);
362 undef_str->WriteUtf8(value); 281 undef_str->WriteUtf8(value);
363 CHECK_EQ(0, strcmp(value, "undefined")); 282 CHECK_EQ(0, strcmp(value, "undefined"));
364 i::DeleteArray(value); 283 i::DeleteArray(value);
(...skipping 24390 matching lines...) Expand 10 before | Expand all | Expand 10 after
24755 "bar2.js"); 24674 "bar2.js");
24756 } 24675 }
24757 24676
24758 24677
24759 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { 24678 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
24760 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", 24679 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24761 " sourceMappingURL=bar2.js\n", "foo();", NULL}; 24680 " sourceMappingURL=bar2.js\n", "foo();", NULL};
24762 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, 24681 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
24763 "bar2.js"); 24682 "bar2.js");
24764 } 24683 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698