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

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

Issue 8839007: Relax test condition to make it less brittle. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 13420 matching lines...) Expand 10 before | Expand all | Expand 10 after
13431 " bar();\n" 13431 " bar();\n"
13432 "}\n" 13432 "}\n"
13433 "foo();\n" 13433 "foo();\n"
13434 "}\n" 13434 "}\n"
13435 "eval('(' + outer +')()//@ sourceURL=eval_url');"; 13435 "eval('(' + outer +')()//@ sourceURL=eval_url');";
13436 CHECK(CompileRun(source)->IsUndefined()); 13436 CHECK(CompileRun(source)->IsUndefined());
13437 } 13437 }
13438 13438
13439 13439
13440 // Test that idle notification can be handled and eventually returns true. 13440 // Test that idle notification can be handled and eventually returns true.
13441 // This just checks the contract of the IdleNotification() function,
13442 // and does not verify that it does reasonable work.
13441 THREADED_TEST(IdleNotification) { 13443 THREADED_TEST(IdleNotification) {
13442 v8::HandleScope scope; 13444 v8::HandleScope scope;
13443 LocalContext env; 13445 LocalContext env;
13444 CompileRun("function binom(n, m) {" 13446 CompileRun("function binom(n, m) {"
13445 " var C = [[1]];" 13447 " var C = [[1]];"
13446 " for (var i = 1; i <= n; ++i) {" 13448 " for (var i = 1; i <= n; ++i) {"
13447 " C[i] = [1];" 13449 " C[i] = [1];"
13448 " for (var j = 1; j < i; ++j) {" 13450 " for (var j = 1; j < i; ++j) {"
13449 " C[i][j] = C[i-1][j-1] + C[i-1][j];" 13451 " C[i][j] = C[i-1][j-1] + C[i-1][j];"
13450 " }" 13452 " }"
13451 " C[i][i] = 1;" 13453 " C[i][i] = 1;"
13452 " }" 13454 " }"
13453 " return C[n][m];" 13455 " return C[n][m];"
13454 "};" 13456 "};"
13455 "binom(1000, 500)"); 13457 "binom(1000, 500)");
13456 bool rv = false; 13458 bool rv = false;
13457 for (int i = 0; i < 100; i++) { 13459 for (int i = 0; i < 100; i++) {
13458 rv = v8::V8::IdleNotification(); 13460 rv = v8::V8::IdleNotification();
13459 if (rv) 13461 if (rv)
13460 break; 13462 break;
13461 } 13463 }
13462 CHECK(rv == true); 13464 CHECK(rv == true);
13463 } 13465 }
13464 13466
13465 // Test that idle notification can be handled and eventually returns true. 13467 // Test that idle notification can be handled and eventually returns true.
13468 // This just checks the contract of the IdleNotification() function,
13469 // and does not verify that it does reasonable work.
13466 THREADED_TEST(IdleNotificationWithHint) { 13470 THREADED_TEST(IdleNotificationWithHint) {
13467 v8::HandleScope scope; 13471 v8::HandleScope scope;
13468 LocalContext env; 13472 LocalContext env;
13469 CompileRun("function binom(n, m) {" 13473 CompileRun("function binom(n, m) {"
13470 " var C = [[1]];" 13474 " var C = [[1]];"
13471 " for (var i = 1; i <= n; ++i) {" 13475 " for (var i = 1; i <= n; ++i) {"
13472 " C[i] = [1];" 13476 " C[i] = [1];"
13473 " for (var j = 1; j < i; ++j) {" 13477 " for (var j = 1; j < i; ++j) {"
13474 " C[i][j] = C[i-1][j-1] + C[i-1][j];" 13478 " C[i][j] = C[i-1][j-1] + C[i-1][j];"
13475 " }" 13479 " }"
13476 " C[i][i] = 1;" 13480 " C[i][i] = 1;"
13477 " }" 13481 " }"
13478 " return C[n][m];" 13482 " return C[n][m];"
13479 "};" 13483 "};"
13480 "binom(1000, 500)"); 13484 "binom(1000, 500)");
13481 bool rv = false; 13485 bool rv = false;
13482 intptr_t old_size = HEAP->SizeOfObjects(); 13486 intptr_t old_size = HEAP->SizeOfObjects();
13483 bool no_idle_work = v8::V8::IdleNotification(10); 13487 bool no_idle_work = v8::V8::IdleNotification(10);
13484 for (int i = 0; i < 200; i++) { 13488 for (int i = 0; i < 200; i++) {
13485 rv = v8::V8::IdleNotification(10); 13489 rv = v8::V8::IdleNotification(10);
13486 if (rv) 13490 if (rv)
13487 break; 13491 break;
13488 } 13492 }
13489 CHECK(rv == true); 13493 CHECK(rv == true);
13490 intptr_t new_size = HEAP->SizeOfObjects(); 13494 intptr_t new_size = HEAP->SizeOfObjects();
13491 CHECK(no_idle_work || new_size < 3 * old_size / 4); 13495 CHECK(no_idle_work || new_size < old_size);
13492 } 13496 }
13493 13497
13494 13498
13495 static uint32_t* stack_limit; 13499 static uint32_t* stack_limit;
13496 13500
13497 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) { 13501 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) {
13498 stack_limit = reinterpret_cast<uint32_t*>( 13502 stack_limit = reinterpret_cast<uint32_t*>(
13499 i::Isolate::Current()->stack_guard()->real_climit()); 13503 i::Isolate::Current()->stack_guard()->real_climit());
13500 return v8::Undefined(); 13504 return v8::Undefined();
13501 } 13505 }
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
15633 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); 15637 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]")));
15634 15638
15635 // TODO(1547): Make the following also return "i". 15639 // TODO(1547): Make the following also return "i".
15636 // Calling with environment record as base. 15640 // Calling with environment record as base.
15637 TestReceiver(o, context->Global(), "func()"); 15641 TestReceiver(o, context->Global(), "func()");
15638 // Calling with no base. 15642 // Calling with no base.
15639 TestReceiver(o, context->Global(), "(1,func)()"); 15643 TestReceiver(o, context->Global(), "(1,func)()");
15640 15644
15641 foreign_context.Dispose(); 15645 foreign_context.Dispose();
15642 } 15646 }
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698