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

Side by Side Diff: tests/language/type_vm_test.dart

Issue 10800002: Hide names of internal classes from the user by mapping them to the documented (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
« no previous file with comments | « tests/language/type_cast_vm_test.dart ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // VMOptions=--enable_type_checks --enable_asserts 4 // VMOptions=--enable_type_checks --no_show_internal_names
5 // 5 //
6 // Dart test program testing type checks. 6 // Dart test program testing type checks.
7 7
8 class TypeTest { 8 class TypeTest {
9 static test() { 9 static test() {
10 int result = 0; 10 int result = 0;
11 try { 11 try {
12 int i = "hello"; // Throws a TypeError if type checks are enabled. 12 int i = "hello"; // Throws a TypeError if type checks are enabled.
13 } catch (TypeError error) { 13 } catch (TypeError error) {
14 result = 1; 14 result = 1;
(...skipping 15 matching lines...) Expand all
30 static testSideEffect() { 30 static testSideEffect() {
31 int result = 0; 31 int result = 0;
32 int index() { 32 int index() {
33 result++; 33 result++;
34 return 0; 34 return 0;
35 } 35 }
36 try { 36 try {
37 List<int> a = new List<int>(1); 37 List<int> a = new List<int>(1);
38 a[0] = 0; 38 a[0] = 0;
39 a[index()]++; // Type check succeeds, but does not create side effects. 39 a[index()]++; // Type check succeeds, but does not create side effects.
40 assert(a[0] == 1); 40 Expect.equals(1, a[0]);
41 } catch (TypeError error) { 41 } catch (TypeError error) {
42 result = 100; 42 result = 100;
43 } 43 }
44 return result; 44 return result;
45 } 45 }
46 46
47 static testArgument() { 47 static testArgument() {
48 int result = 0; 48 int result = 0;
49 int f(int i) { 49 int f(int i) {
50 return i; 50 return i;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 result++; 361 result++;
362 Expect.equals("C", error.dstType); 362 Expect.equals("C", error.dstType);
363 Expect.equals("int", error.srcType); 363 Expect.equals("int", error.srcType);
364 Expect.equals("function result", error.dstName); 364 Expect.equals("function result", error.dstName);
365 int pos = error.url.lastIndexOf("/", error.url.length); 365 int pos = error.url.lastIndexOf("/", error.url.length);
366 if (pos == -1) { 366 if (pos == -1) {
367 pos = error.url.lastIndexOf("\\", error.url.length); 367 pos = error.url.lastIndexOf("\\", error.url.length);
368 } 368 }
369 String subs = error.url.substring(pos + 1, error.url.length); 369 String subs = error.url.substring(pos + 1, error.url.length);
370 Expect.equals("type_vm_test.dart", subs); 370 Expect.equals("type_vm_test.dart", subs);
371 Expect.equals(472, error.line); 371 Expect.equals(560, error.line);
372 Expect.equals(12, error.column); 372 Expect.equals(12, error.column);
373 } 373 }
374 return result; 374 return result;
375 } 375 }
376 376
377 static int testListAssigment() { 377 static int testListAssigment() {
378 int result = 0; 378 int result = 0;
379 { 379 {
380 var a = new List(5); 380 var a = new List(5);
381 List a0 = a; 381 List a0 = a;
382 List<Object> ao = a; 382 List<Object> ao = a;
383 List<int> ai = a; 383 List<int> ai = a;
384 List<num> an = a; 384 List<num> an = a;
385 List<String> as = a; 385 List<String> as = a;
386 } 386 }
387 { 387 {
388 var a = new List<Object>(5); 388 var a = new List<Object>(5);
389 List a0 = a; 389 List a0 = a;
390 List<Object> ao = a; 390 List<Object> ao = a;
391 try { 391 try {
392 List<int> ai = a; 392 List<int> ai = a;
393 } catch (TypeError error) { 393 } catch (TypeError error) {
394 result++; 394 result++;
395 Expect.equals("List<int>", error.dstType);
396 Expect.equals("List<Object>", error.srcType);
397 Expect.equals("ai", error.dstName);
398 int pos = error.url.lastIndexOf("/", error.url.length);
399 if (pos == -1) {
400 pos = error.url.lastIndexOf("\\", error.url.length);
401 }
402 String subs = error.url.substring(pos + 1, error.url.length);
403 Expect.equals("type_vm_test.dart", subs);
404 Expect.equals(392, error.line);
405 Expect.equals(24, error.column);
395 } 406 }
396 try { 407 try {
397 List<num> an = a; 408 List<num> an = a;
398 } catch (TypeError error) { 409 } catch (TypeError error) {
399 result++; 410 result++;
411 Expect.equals("List<num>", error.dstType);
412 Expect.equals("List<Object>", error.srcType);
413 Expect.equals("an", error.dstName);
414 int pos = error.url.lastIndexOf("/", error.url.length);
415 if (pos == -1) {
416 pos = error.url.lastIndexOf("\\", error.url.length);
417 }
418 String subs = error.url.substring(pos + 1, error.url.length);
419 Expect.equals("type_vm_test.dart", subs);
420 Expect.equals(408, error.line);
421 Expect.equals(24, error.column);
400 } 422 }
401 try { 423 try {
402 List<String> as = a; 424 List<String> as = a;
403 } catch (TypeError error) { 425 } catch (TypeError error) {
404 result++; 426 result++;
427 Expect.equals("List<String>", error.dstType);
428 Expect.equals("List<Object>", error.srcType);
429 Expect.equals("as", error.dstName);
430 int pos = error.url.lastIndexOf("/", error.url.length);
431 if (pos == -1) {
432 pos = error.url.lastIndexOf("\\", error.url.length);
433 }
434 String subs = error.url.substring(pos + 1, error.url.length);
435 Expect.equals("type_vm_test.dart", subs);
436 Expect.equals(424, error.line);
437 Expect.equals(27, error.column);
405 } 438 }
406 } 439 }
407 { 440 {
408 var a = new List<int>(5); 441 var a = new List<int>(5);
409 List a0 = a; 442 List a0 = a;
410 List<Object> ao = a; 443 List<Object> ao = a;
411 List<int> ai = a; 444 List<int> ai = a;
412 List<num> an = a; 445 List<num> an = a;
413 try { 446 try {
414 List<String> as = a; 447 List<String> as = a;
415 } catch (TypeError error) { 448 } catch (TypeError error) {
416 result++; 449 result++;
450 Expect.equals("List<String>", error.dstType);
451 Expect.equals("List<int>", error.srcType);
452 Expect.equals("as", error.dstName);
453 int pos = error.url.lastIndexOf("/", error.url.length);
454 if (pos == -1) {
455 pos = error.url.lastIndexOf("\\", error.url.length);
456 }
457 String subs = error.url.substring(pos + 1, error.url.length);
458 Expect.equals("type_vm_test.dart", subs);
459 Expect.equals(447, error.line);
460 Expect.equals(27, error.column);
417 } 461 }
418 } 462 }
419 { 463 {
420 var a = new List<num>(5); 464 var a = new List<num>(5);
421 List a0 = a; 465 List a0 = a;
422 List<Object> ao = a; 466 List<Object> ao = a;
423 try { 467 try {
424 List<int> ai = a; 468 List<int> ai = a;
425 } catch (TypeError error) { 469 } catch (TypeError error) {
426 result++; 470 result++;
471 Expect.equals("List<int>", error.dstType);
472 Expect.equals("List<num>", error.srcType);
473 Expect.equals("ai", error.dstName);
474 int pos = error.url.lastIndexOf("/", error.url.length);
475 if (pos == -1) {
476 pos = error.url.lastIndexOf("\\", error.url.length);
477 }
478 String subs = error.url.substring(pos + 1, error.url.length);
479 Expect.equals("type_vm_test.dart", subs);
480 Expect.equals(468, error.line);
481 Expect.equals(24, error.column);
427 } 482 }
428 List<num> an = a; 483 List<num> an = a;
429 try { 484 try {
430 List<String> as = a; 485 List<String> as = a;
431 } catch (TypeError error) { 486 } catch (TypeError error) {
432 result++; 487 result++;
488 Expect.equals("List<String>", error.dstType);
489 Expect.equals("List<num>", error.srcType);
490 Expect.equals("as", error.dstName);
491 int pos = error.url.lastIndexOf("/", error.url.length);
492 if (pos == -1) {
493 pos = error.url.lastIndexOf("\\", error.url.length);
494 }
495 String subs = error.url.substring(pos + 1, error.url.length);
496 Expect.equals("type_vm_test.dart", subs);
497 Expect.equals(485, error.line);
498 Expect.equals(27, error.column);
433 } 499 }
434 } 500 }
435 { 501 {
436 var a = new List<String>(5); 502 var a = new List<String>(5);
437 List a0 = a; 503 List a0 = a;
438 List<Object> ao = a; 504 List<Object> ao = a;
439 try { 505 try {
440 List<int> ai = a; 506 List<int> ai = a;
441 } catch (TypeError error) { 507 } catch (TypeError error) {
442 result++; 508 result++;
509 Expect.equals("List<int>", error.dstType);
510 Expect.equals("List<String>", error.srcType);
511 Expect.equals("ai", error.dstName);
512 int pos = error.url.lastIndexOf("/", error.url.length);
513 if (pos == -1) {
514 pos = error.url.lastIndexOf("\\", error.url.length);
515 }
516 String subs = error.url.substring(pos + 1, error.url.length);
517 Expect.equals("type_vm_test.dart", subs);
518 Expect.equals(506, error.line);
519 Expect.equals(24, error.column);
443 } 520 }
444 try { 521 try {
445 List<num> an = a; 522 List<num> an = a;
446 } catch (TypeError error) { 523 } catch (TypeError error) {
447 result++; 524 result++;
525 Expect.equals("List<num>", error.dstType);
526 Expect.equals("List<String>", error.srcType);
527 Expect.equals("an", error.dstName);
528 int pos = error.url.lastIndexOf("/", error.url.length);
529 if (pos == -1) {
530 pos = error.url.lastIndexOf("\\", error.url.length);
531 }
532 String subs = error.url.substring(pos + 1, error.url.length);
533 Expect.equals("type_vm_test.dart", subs);
534 Expect.equals(522, error.line);
535 Expect.equals(24, error.column);
448 } 536 }
449 List<String> as = a; 537 List<String> as = a;
450 } 538 }
451 return result; 539 return result;
452 } 540 }
453 541
454 static testMain() { 542 static testMain() {
455 Expect.equals(1, test()); 543 Expect.equals(1, test());
456 Expect.equals(1, testSideEffect()); 544 Expect.equals(1, testSideEffect());
457 Expect.equals(1, testArgument()); 545 Expect.equals(1, testArgument());
(...skipping 12 matching lines...) Expand all
470 class C { 558 class C {
471 factory C() { 559 factory C() {
472 return 1; // Implicit result type is 'C', not int. 560 return 1; // Implicit result type is 'C', not int.
473 } 561 }
474 } 562 }
475 563
476 564
477 main() { 565 main() {
478 TypeTest.testMain(); 566 TypeTest.testMain();
479 } 567 }
OLDNEW
« no previous file with comments | « tests/language/type_cast_vm_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698