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

Side by Side Diff: runtime/vm/debugger_api_impl_test.cc

Issue 10704216: Fix type checking of void type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 OS::Print(" >> bpt nr %d: %s\n", breakpoint_hit_counter, name_chars); 312 OS::Print(" >> bpt nr %d: %s\n", breakpoint_hit_counter, name_chars);
313 } 313 }
314 breakpoint_hit = true; 314 breakpoint_hit = true;
315 breakpoint_hit_counter++; 315 breakpoint_hit_counter++;
316 Dart_SetStepOut(); 316 Dart_SetStepOut();
317 } 317 }
318 318
319 319
320 TEST_CASE(Debug_StepOut) { 320 TEST_CASE(Debug_StepOut) {
321 const char* kScriptChars = 321 const char* kScriptChars =
322 "void f1() { return 1; } \n" 322 "f1() { return 1; } \n"
323 "void f2() { return 2; } \n" 323 "f2() { return 2; } \n"
324 " \n" 324 " \n"
325 "void foo() { \n" 325 "foo() { \n"
326 " f1(); \n" 326 " f1(); \n"
327 " return f2(); \n" 327 " return f2(); \n"
328 "} \n" 328 "} \n"
329 " \n" 329 " \n"
330 "void main() { \n" 330 "main() { \n"
331 " return foo(); \n" 331 " return foo(); \n"
332 "} \n"; 332 "} \n";
333 333
334 LoadScript(kScriptChars); 334 LoadScript(kScriptChars);
335 Dart_SetBreakpointHandler(&TestStepOutHandler); 335 Dart_SetBreakpointHandler(&TestStepOutHandler);
336 336
337 // Set a breakpoint in function f1, then repeatedly step out until 337 // Set a breakpoint in function f1, then repeatedly step out until
338 // we get to main. We should see one breakpoint each in f1, 338 // we get to main. We should see one breakpoint each in f1,
339 // foo, main, but not in f2. 339 // foo, main, but not in f2.
340 SetBreakpointAtEntry("", "f1"); 340 SetBreakpointAtEntry("", "f1");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 OS::Print(" >> bpt nr %d: %s\n", breakpoint_hit_counter, name_chars); 386 OS::Print(" >> bpt nr %d: %s\n", breakpoint_hit_counter, name_chars);
387 } 387 }
388 breakpoint_hit = true; 388 breakpoint_hit = true;
389 breakpoint_hit_counter++; 389 breakpoint_hit_counter++;
390 Dart_SetStepInto(); 390 Dart_SetStepInto();
391 } 391 }
392 392
393 393
394 TEST_CASE(Debug_StepInto) { 394 TEST_CASE(Debug_StepInto) {
395 const char* kScriptChars = 395 const char* kScriptChars =
396 "void f1() { return 1; } \n" 396 "f1() { return 1; } \n"
397 "void f2() { return 2; } \n" 397 "f2() { return 2; } \n"
398 " \n" 398 " \n"
399 "class X { \n" 399 "class X { \n"
400 " kvmk(a, [b, c]) { \n" 400 " kvmk(a, [b, c]) { \n"
401 " return c + f2(); \n" 401 " return c + f2(); \n"
402 " } \n" 402 " } \n"
403 "} \n" 403 "} \n"
404 " \n" 404 " \n"
405 "void foo() { \n" 405 "foo() { \n"
406 " f1(); \n" 406 " f1(); \n"
407 " var o = new X(); \n" 407 " var o = new X(); \n"
408 " return o.kvmk(3, c:5); \n" 408 " return o.kvmk(3, c:5); \n"
409 "} \n" 409 "} \n"
410 " \n" 410 " \n"
411 "void main() { \n" 411 "main() { \n"
412 " return foo(); \n" 412 " return foo(); \n"
413 "} \n"; 413 "} \n";
414 414
415 LoadScript(kScriptChars); 415 LoadScript(kScriptChars);
416 Dart_SetBreakpointHandler(&TestStepIntoHandler); 416 Dart_SetBreakpointHandler(&TestStepIntoHandler);
417 417
418 // Set a breakpoint in function f1, then repeatedly step out until 418 // Set a breakpoint in function f1, then repeatedly step out until
419 // we get to main. We should see one breakpoint each in f1, 419 // we get to main. We should see one breakpoint each in f1,
420 // foo, main, but not in f2. 420 // foo, main, but not in f2.
421 SetBreakpointAtEntry("", "main"); 421 SetBreakpointAtEntry("", "main");
(...skipping 24 matching lines...) Expand all
446 446
447 TEST_CASE(Debug_IgnoreBP) { 447 TEST_CASE(Debug_IgnoreBP) {
448 const char* kScriptChars = 448 const char* kScriptChars =
449 "class B { \n" 449 "class B { \n"
450 " static var z = 0; \n" 450 " static var z = 0; \n"
451 " var i = 100; \n" 451 " var i = 100; \n"
452 " var d = 3.14; \n" 452 " var d = 3.14; \n"
453 " var s = 'Dr Seuss'; \n" 453 " var s = 'Dr Seuss'; \n"
454 "} \n" 454 "} \n"
455 " \n" 455 " \n"
456 "void main() { \n" 456 "main() { \n"
457 " var x = new B(); \n" 457 " var x = new B(); \n"
458 " return x.i + 1; \n" 458 " return x.i + 1; \n"
459 "} \n"; 459 "} \n";
460 460
461 LoadScript(kScriptChars); 461 LoadScript(kScriptChars);
462 Dart_SetBreakpointHandler(&StepIntoHandler); 462 Dart_SetBreakpointHandler(&StepIntoHandler);
463 463
464 SetBreakpointAtEntry("", "main"); 464 SetBreakpointAtEntry("", "main");
465 465
466 breakpoint_hit = false; 466 breakpoint_hit = false;
467 breakpoint_hit_counter = 0; 467 breakpoint_hit_counter = 0;
468 Dart_Handle retval = Invoke("main"); 468 Dart_Handle retval = Invoke("main");
469 EXPECT(!Dart_IsError(retval)); 469 EXPECT(!Dart_IsError(retval));
470 EXPECT(Dart_IsInteger(retval)); 470 EXPECT(Dart_IsInteger(retval));
471 int64_t int_value = 0; 471 int64_t int_value = 0;
472 Dart_IntegerToInt64(retval, &int_value); 472 Dart_IntegerToInt64(retval, &int_value);
473 EXPECT_EQ(101, int_value); 473 EXPECT_EQ(101, int_value);
474 EXPECT(breakpoint_hit == true); 474 EXPECT(breakpoint_hit == true);
475 } 475 }
476 476
477 477
478 TEST_CASE(Debug_DeoptimizeFunction) { 478 TEST_CASE(Debug_DeoptimizeFunction) {
479 const char* kScriptChars = 479 const char* kScriptChars =
480 "foo(x) => 2 * x; \n" 480 "foo(x) => 2 * x; \n"
481 " \n" 481 " \n"
482 "warmup() { \n" 482 "warmup() { \n"
483 " for (int i = 0; i < 5000; i++) { \n" 483 " for (int i = 0; i < 5000; i++) { \n"
484 " foo(i); \n" 484 " foo(i); \n"
485 " } \n" 485 " } \n"
486 "} \n" 486 "} \n"
487 " \n" 487 " \n"
488 "void main() { \n" 488 "main() { \n"
489 " return foo(99); \n" 489 " return foo(99); \n"
490 "} \n"; 490 "} \n";
491 491
492 LoadScript(kScriptChars); 492 LoadScript(kScriptChars);
493 Dart_SetBreakpointHandler(&StepIntoHandler); 493 Dart_SetBreakpointHandler(&StepIntoHandler);
494 494
495 495
496 // Cause function foo to be optimized before we set a BP. 496 // Cause function foo to be optimized before we set a BP.
497 Dart_Handle res = Invoke("warmup"); 497 Dart_Handle res = Invoke("warmup");
498 EXPECT_NOT_ERROR(res); 498 EXPECT_NOT_ERROR(res);
499 499
500 // Now set breakpoint in main and then step into optimized function foo. 500 // Now set breakpoint in main and then step into optimized function foo.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 EXPECT_STREQ(expected_bpts[breakpoint_hit_counter], name_chars); 537 EXPECT_STREQ(expected_bpts[breakpoint_hit_counter], name_chars);
538 } 538 }
539 breakpoint_hit = true; 539 breakpoint_hit = true;
540 breakpoint_hit_counter++; 540 breakpoint_hit_counter++;
541 Dart_SetStepOver(); 541 Dart_SetStepOver();
542 } 542 }
543 543
544 544
545 TEST_CASE(Debug_SingleStep) { 545 TEST_CASE(Debug_SingleStep) {
546 const char* kScriptChars = 546 const char* kScriptChars =
547 "void moo(s) { return 1; } \n" 547 "moo(s) { return 1; } \n"
548 " \n" 548 " \n"
549 "void foo() { \n" 549 "void foo() { \n"
550 " moo('step one'); \n" 550 " moo('step one'); \n"
551 " moo('step two'); \n" 551 " moo('step two'); \n"
552 " moo('step three'); \n" 552 " moo('step three'); \n"
553 "} \n" 553 "} \n"
554 " \n" 554 " \n"
555 "void main() { \n" 555 "void main() { \n"
556 " foo(); \n" 556 " foo(); \n"
557 "} \n"; 557 "} \n";
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 list_as_string = Dart_ToString(lib_list); 1042 list_as_string = Dart_ToString(lib_list);
1043 list_cstr = ""; 1043 list_cstr = "";
1044 EXPECT_VALID(Dart_StringToCString(list_as_string, &list_cstr)); 1044 EXPECT_VALID(Dart_StringToCString(list_as_string, &list_cstr));
1045 EXPECT_SUBSTRING(TestCase::url(), list_cstr); 1045 EXPECT_SUBSTRING(TestCase::url(), list_cstr);
1046 } 1046 }
1047 1047
1048 1048
1049 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 1049 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
1050 1050
1051 } // namespace dart 1051 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698