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

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest.dart

Issue 685573002: Inline JUnitTestCase 'assert' methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.all_the_rest_test; 8 library engine.all_the_rest_test;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
11 11
12 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 12 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
13 import 'package:analyzer/src/generated/constant.dart'; 13 import 'package:analyzer/src/generated/constant.dart';
14 import 'package:analyzer/src/generated/element.dart'; 14 import 'package:analyzer/src/generated/element.dart';
15 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
16 import 'package:analyzer/src/generated/error.dart'; 16 import 'package:analyzer/src/generated/error.dart';
17 import 'package:analyzer/src/generated/html.dart' as ht; 17 import 'package:analyzer/src/generated/html.dart' as ht;
18 import 'package:analyzer/src/generated/java_core.dart'; 18 import 'package:analyzer/src/generated/java_core.dart';
19 import 'package:analyzer/src/generated/java_engine.dart'; 19 import 'package:analyzer/src/generated/java_engine.dart';
20 import 'package:analyzer/src/generated/java_engine_io.dart'; 20 import 'package:analyzer/src/generated/java_engine_io.dart';
21 import 'package:analyzer/src/generated/java_io.dart'; 21 import 'package:analyzer/src/generated/java_io.dart';
22 import 'package:analyzer/src/generated/java_junit.dart';
23 import 'package:analyzer/src/generated/resolver.dart'; 22 import 'package:analyzer/src/generated/resolver.dart';
24 import 'package:analyzer/src/generated/scanner.dart'; 23 import 'package:analyzer/src/generated/scanner.dart';
25 import 'package:analyzer/src/generated/sdk.dart'; 24 import 'package:analyzer/src/generated/sdk.dart';
26 import 'package:analyzer/src/generated/sdk_io.dart'; 25 import 'package:analyzer/src/generated/sdk_io.dart';
27 import 'package:analyzer/src/generated/source.dart'; 26 import 'package:analyzer/src/generated/source.dart';
28 import 'package:analyzer/src/generated/source_io.dart'; 27 import 'package:analyzer/src/generated/source_io.dart';
29 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 28 import 'package:analyzer/src/generated/testing/ast_factory.dart';
30 import 'package:analyzer/src/generated/testing/element_factory.dart'; 29 import 'package:analyzer/src/generated/testing/element_factory.dart';
31 import 'package:analyzer/src/generated/testing/html_factory.dart'; 30 import 'package:analyzer/src/generated/testing/html_factory.dart';
32 import 'package:analyzer/src/generated/utilities_collection.dart'; 31 import 'package:analyzer/src/generated/utilities_collection.dart';
33 import 'package:analyzer/src/generated/utilities_dart.dart'; 32 import 'package:analyzer/src/generated/utilities_dart.dart';
34 import 'package:unittest/unittest.dart' as _ut; 33 import 'package:unittest/unittest.dart';
35 34
36 import '../reflective_tests.dart'; 35 import '../reflective_tests.dart';
37 import 'parser_test.dart'; 36 import 'parser_test.dart';
38 import 'resolver_test.dart'; 37 import 'resolver_test.dart';
39 import 'test_support.dart'; 38 import 'test_support.dart';
40 39
41 40
42 main() { 41 main() {
43 _ut.groupSep = ' | '; 42 groupSep = ' | ';
44 runReflectiveTests(AngularCompilationUnitBuilderTest); 43 runReflectiveTests(AngularCompilationUnitBuilderTest);
45 runReflectiveTests(AngularHtmlUnitResolverTest); 44 runReflectiveTests(AngularHtmlUnitResolverTest);
46 runReflectiveTests(AngularHtmlUnitUtilsTest); 45 runReflectiveTests(AngularHtmlUnitUtilsTest);
47 runReflectiveTests(ConstantEvaluatorTest); 46 runReflectiveTests(ConstantEvaluatorTest);
48 runReflectiveTests(ConstantFinderTest); 47 runReflectiveTests(ConstantFinderTest);
49 runReflectiveTests(ConstantValueComputerTest); 48 runReflectiveTests(ConstantValueComputerTest);
50 runReflectiveTests(ConstantVisitorTest); 49 runReflectiveTests(ConstantVisitorTest);
51 runReflectiveTests(ContentCacheTest); 50 runReflectiveTests(ContentCacheTest);
52 runReflectiveTests(DartObjectImplTest); 51 runReflectiveTests(DartObjectImplTest);
53 runReflectiveTests(DartUriResolverTest); 52 runReflectiveTests(DartUriResolverTest);
(...skipping 13 matching lines...) Expand all
67 runReflectiveTests(HtmlUnitBuilderTest); 66 runReflectiveTests(HtmlUnitBuilderTest);
68 runReflectiveTests(HtmlWarningCodeTest); 67 runReflectiveTests(HtmlWarningCodeTest);
69 runReflectiveTests(ReferenceFinderTest); 68 runReflectiveTests(ReferenceFinderTest);
70 runReflectiveTests(SDKLibrariesReaderTest); 69 runReflectiveTests(SDKLibrariesReaderTest);
71 runReflectiveTests(SourceFactoryTest); 70 runReflectiveTests(SourceFactoryTest);
72 runReflectiveTests(ToSourceVisitorTest); 71 runReflectiveTests(ToSourceVisitorTest);
73 runReflectiveTests(UriKindTest); 72 runReflectiveTests(UriKindTest);
74 runReflectiveTests(StringScannerTest); 73 runReflectiveTests(StringScannerTest);
75 } 74 }
76 75
77 abstract class AbstractScannerTest extends JUnitTestCase { 76 abstract class AbstractScannerTest {
78 ht.AbstractScanner newScanner(String input); 77 ht.AbstractScanner newScanner(String input);
79 78
80 void test_tokenize_attribute() { 79 void test_tokenize_attribute() {
81 _tokenize( 80 _tokenize(
82 "<html bob=\"one two\">", 81 "<html bob=\"one two\">",
83 <Object>[ 82 <Object>[
84 ht.TokenType.LT, 83 ht.TokenType.LT,
85 "html", 84 "html",
86 "bob", 85 "bob",
87 ht.TokenType.EQ, 86 ht.TokenType.EQ,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ht.TokenType.LT_SLASH, 242 ht.TokenType.LT_SLASH,
244 "p", 243 "p",
245 ht.TokenType.GT, 244 ht.TokenType.GT,
246 " ", 245 " ",
247 ht.TokenType.LT_SLASH, 246 ht.TokenType.LT_SLASH,
248 "html", 247 "html",
249 ht.TokenType.GT, 248 ht.TokenType.GT,
250 " "], 249 " "],
251 <int>[0, 9, 21, 25, 28, 38, 49]); 250 <int>[0, 9, 21, 25, 28, 38, 49]);
252 token = token.next; 251 token = token.next;
253 JUnitTestCase.assertEquals(1, token.offset); 252 expect(token.offset, 1);
254 token = token.next; 253 token = token.next;
255 JUnitTestCase.assertEquals(3, token.offset); 254 expect(token.offset, 3);
256 token = token.next; 255 token = token.next;
257 JUnitTestCase.assertEquals(10, token.offset); 256 expect(token.offset, 10);
258 } 257 }
259 258
260 void test_tokenize_string() { 259 void test_tokenize_string() {
261 _tokenize( 260 _tokenize(
262 "<p bob=\"foo\">", 261 "<p bob=\"foo\">",
263 <Object>[ 262 <Object>[
264 ht.TokenType.LT, 263 ht.TokenType.LT,
265 "p", 264 "p",
266 "bob", 265 "bob",
267 ht.TokenType.EQ, 266 ht.TokenType.EQ,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ht.TokenType.GT, 301 ht.TokenType.GT,
303 ht.TokenType.LT_SLASH, 302 ht.TokenType.LT_SLASH,
304 "html", 303 "html",
305 ht.TokenType.GT]); 304 ht.TokenType.GT]);
306 } 305 }
307 306
308 void test_tokenize_tag_begin_only() { 307 void test_tokenize_tag_begin_only() {
309 ht.Token token = 308 ht.Token token =
310 _tokenize("<html>", <Object>[ht.TokenType.LT, "html", ht.TokenType.GT]); 309 _tokenize("<html>", <Object>[ht.TokenType.LT, "html", ht.TokenType.GT]);
311 token = token.next; 310 token = token.next;
312 JUnitTestCase.assertEquals(1, token.offset); 311 expect(token.offset, 1);
313 } 312 }
314 313
315 void test_tokenize_tag_incomplete_with_special_characters() { 314 void test_tokenize_tag_incomplete_with_special_characters() {
316 _tokenize("<br-a_b", <Object>[ht.TokenType.LT, "br-a_b"]); 315 _tokenize("<br-a_b", <Object>[ht.TokenType.LT, "br-a_b"]);
317 } 316 }
318 317
319 void test_tokenize_tag_self_contained() { 318 void test_tokenize_tag_self_contained() {
320 _tokenize("<br/>", <Object>[ht.TokenType.LT, "br", ht.TokenType.SLASH_GT]); 319 _tokenize("<br/>", <Object>[ht.TokenType.LT, "br", ht.TokenType.SLASH_GT]);
321 } 320 }
322 321
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return ht.TokenType.DECLARATION; 361 return ht.TokenType.DECLARATION;
363 } 362 }
364 if (lexeme.startsWith("<?")) { 363 if (lexeme.startsWith("<?")) {
365 return ht.TokenType.DIRECTIVE; 364 return ht.TokenType.DIRECTIVE;
366 } 365 }
367 if (_isTag(lexeme)) { 366 if (_isTag(lexeme)) {
368 return ht.TokenType.TAG; 367 return ht.TokenType.TAG;
369 } 368 }
370 return ht.TokenType.TEXT; 369 return ht.TokenType.TEXT;
371 } 370 }
372 JUnitTestCase.fail( 371 fail("Unknown expected token $count: ${expected != null ? expected.runtimeTy pe : "null"}");
373 "Unknown expected token $count: ${expected != null ? expected.runtimeTyp e : "null"}");
374 return null; 372 return null;
375 } 373 }
376 374
377 bool _isTag(String lexeme) { 375 bool _isTag(String lexeme) {
378 if (lexeme.length == 0 || !Character.isLetter(lexeme.codeUnitAt(0))) { 376 if (lexeme.length == 0 || !Character.isLetter(lexeme.codeUnitAt(0))) {
379 return false; 377 return false;
380 } 378 }
381 for (int index = 1; index < lexeme.length; index++) { 379 for (int index = 1; index < lexeme.length; index++) {
382 int ch = lexeme.codeUnitAt(index); 380 int ch = lexeme.codeUnitAt(index);
383 if (!Character.isLetterOrDigit(ch) && ch != 0x2D && ch != 0x5F) { 381 if (!Character.isLetterOrDigit(ch) && ch != 0x2D && ch != 0x5F) {
384 return false; 382 return false;
385 } 383 }
386 } 384 }
387 return true; 385 return true;
388 } 386 }
389 387
390 ht.Token _tokenize(String input, List<Object> expectedTokens) => 388 ht.Token _tokenize(String input, List<Object> expectedTokens) =>
391 _tokenize2(input, expectedTokens, <int>[0]); 389 _tokenize2(input, expectedTokens, <int>[0]);
392 ht.Token _tokenize2(String input, List<Object> expectedTokens, 390 ht.Token _tokenize2(String input, List<Object> expectedTokens,
393 List<int> expectedLineStarts) { 391 List<int> expectedLineStarts) {
394 ht.AbstractScanner scanner = newScanner(input); 392 ht.AbstractScanner scanner = newScanner(input);
395 scanner.passThroughElements = <String>["script"]; 393 scanner.passThroughElements = <String>["script"];
396 int count = 0; 394 int count = 0;
397 ht.Token firstToken = scanner.tokenize(); 395 ht.Token firstToken = scanner.tokenize();
398 ht.Token token = firstToken; 396 ht.Token token = firstToken;
399 ht.Token previousToken = token.previous; 397 ht.Token previousToken = token.previous;
400 JUnitTestCase.assertTrue(previousToken.type == ht.TokenType.EOF); 398 expect(previousToken.type == ht.TokenType.EOF, isTrue);
401 JUnitTestCase.assertSame(previousToken, previousToken.previous); 399 expect(previousToken.previous, same(previousToken));
402 JUnitTestCase.assertEquals(-1, previousToken.offset); 400 expect(previousToken.offset, -1);
403 JUnitTestCase.assertSame(token, previousToken.next); 401 expect(previousToken.next, same(token));
404 JUnitTestCase.assertEquals(0, token.offset); 402 expect(token.offset, 0);
405 while (token.type != ht.TokenType.EOF) { 403 while (token.type != ht.TokenType.EOF) {
406 if (count == expectedTokens.length) { 404 if (count == expectedTokens.length) {
407 JUnitTestCase.fail("too many parsed tokens"); 405 fail("too many parsed tokens");
408 } 406 }
409 Object expected = expectedTokens[count]; 407 Object expected = expectedTokens[count];
410 ht.TokenType expectedTokenType = _getExpectedTokenType(count, expected); 408 ht.TokenType expectedTokenType = _getExpectedTokenType(count, expected);
411 JUnitTestCase.assertSameMsg( 409 expect(token.type, same(expectedTokenType), reason: "token $count");
412 "token $count",
413 expectedTokenType,
414 token.type);
415 if (expectedTokenType.lexeme != null) { 410 if (expectedTokenType.lexeme != null) {
416 JUnitTestCase.assertEqualsMsg( 411 expect(token.lexeme, expectedTokenType.lexeme, reason: "token $count");
417 "token $count",
418 expectedTokenType.lexeme,
419 token.lexeme);
420 } else { 412 } else {
421 JUnitTestCase.assertEqualsMsg("token $count", expected, token.lexeme); 413 expect(token.lexeme, expected, reason: "token $count");
422 } 414 }
423 count++; 415 count++;
424 previousToken = token; 416 previousToken = token;
425 token = token.next; 417 token = token.next;
426 JUnitTestCase.assertSame(previousToken, token.previous); 418 expect(token.previous, same(previousToken));
427 } 419 }
428 JUnitTestCase.assertSame(token, token.next); 420 expect(token.next, same(token));
429 JUnitTestCase.assertEquals(input.length, token.offset); 421 expect(token.offset, input.length);
430 if (count != expectedTokens.length) { 422 if (count != expectedTokens.length) {
431 JUnitTestCase.assertTrueMsg("not enough parsed tokens", false); 423 expect(false, isTrue, reason: "not enough parsed tokens");
432 } 424 }
433 List<int> lineStarts = scanner.lineStarts; 425 List<int> lineStarts = scanner.lineStarts;
434 bool success = expectedLineStarts.length == lineStarts.length; 426 bool success = expectedLineStarts.length == lineStarts.length;
435 if (success) { 427 if (success) {
436 for (int i = 0; i < lineStarts.length; i++) { 428 for (int i = 0; i < lineStarts.length; i++) {
437 if (expectedLineStarts[i] != lineStarts[i]) { 429 if (expectedLineStarts[i] != lineStarts[i]) {
438 success = false; 430 success = false;
439 break; 431 break;
440 } 432 }
441 } 433 }
442 } 434 }
443 if (!success) { 435 if (!success) {
444 StringBuffer buffer = new StringBuffer(); 436 StringBuffer buffer = new StringBuffer();
445 buffer.write("Expected line starts "); 437 buffer.write("Expected line starts ");
446 for (int start in expectedLineStarts) { 438 for (int start in expectedLineStarts) {
447 buffer.write(start); 439 buffer.write(start);
448 buffer.write(", "); 440 buffer.write(", ");
449 } 441 }
450 buffer.write(" but found "); 442 buffer.write(" but found ");
451 for (int start in lineStarts) { 443 for (int start in lineStarts) {
452 buffer.write(start); 444 buffer.write(start);
453 buffer.write(", "); 445 buffer.write(", ");
454 } 446 }
455 JUnitTestCase.fail(buffer.toString()); 447 fail(buffer.toString());
456 } 448 }
457 return firstToken; 449 return firstToken;
458 } 450 }
459 } 451 }
460 452
461 453
462 class AngularCompilationUnitBuilderTest extends AngularTest { 454 class AngularCompilationUnitBuilderTest extends AngularTest {
463 void test_Decorator() { 455 void test_Decorator() {
464 String mainContent = _createAngularSource(r''' 456 String mainContent = _createAngularSource(r'''
465 @Decorator(selector: '[my-dir]', 457 @Decorator(selector: '[my-dir]',
466 map: const { 458 map: const {
467 'my-dir' : '=>myPropA', 459 'my-dir' : '=>myPropA',
468 '.' : '&myPropB', 460 '.' : '&myPropB',
469 }) 461 })
470 class MyDirective { 462 class MyDirective {
471 set myPropA(value) {} 463 set myPropA(value) {}
472 set myPropB(value) {} 464 set myPropB(value) {}
473 @NgTwoWay('my-prop-c') 465 @NgTwoWay('my-prop-c')
474 String myPropC; 466 String myPropC;
475 }'''); 467 }''');
476 resolveMainSourceNoErrors(mainContent); 468 resolveMainSourceNoErrors(mainContent);
477 // prepare AngularDirectiveElement 469 // prepare AngularDirectiveElement
478 ClassElement classElement = mainUnitElement.getType("MyDirective"); 470 ClassElement classElement = mainUnitElement.getType("MyDirective");
479 AngularDecoratorElement directive = 471 AngularDecoratorElement directive =
480 getAngularElement(classElement, (e) => e is AngularDecoratorElement); 472 getAngularElement(classElement, (e) => e is AngularDecoratorElement);
481 JUnitTestCase.assertNotNull(directive); 473 expect(directive, isNotNull);
482 // verify 474 // verify
483 JUnitTestCase.assertEquals(null, directive.name); 475 expect(directive.name, null);
484 JUnitTestCase.assertEquals(-1, directive.nameOffset); 476 expect(directive.nameOffset, -1);
485 _assertHasAttributeSelector(directive.selector, "my-dir"); 477 _assertHasAttributeSelector(directive.selector, "my-dir");
486 // verify properties 478 // verify properties
487 List<AngularPropertyElement> properties = directive.properties; 479 List<AngularPropertyElement> properties = directive.properties;
488 EngineTestCase.assertLength(3, properties); 480 EngineTestCase.assertLength(3, properties);
489 _assertProperty( 481 _assertProperty(
490 properties[0], 482 properties[0],
491 "my-dir", 483 "my-dir",
492 findMainOffset("my-dir' :"), 484 findMainOffset("my-dir' :"),
493 AngularPropertyKind.ONE_WAY, 485 AngularPropertyKind.ONE_WAY,
494 "myPropA", 486 "myPropA",
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 String mainContent = _createAngularSource(r''' 537 String mainContent = _createAngularSource(r'''
546 @Formatter(name: 'myFilter') 538 @Formatter(name: 'myFilter')
547 class MyFilter { 539 class MyFilter {
548 call(p1, p2) {} 540 call(p1, p2) {}
549 }'''); 541 }''');
550 resolveMainSourceNoErrors(mainContent); 542 resolveMainSourceNoErrors(mainContent);
551 // prepare AngularFilterElement 543 // prepare AngularFilterElement
552 ClassElement classElement = mainUnitElement.getType("MyFilter"); 544 ClassElement classElement = mainUnitElement.getType("MyFilter");
553 AngularFormatterElement filter = 545 AngularFormatterElement filter =
554 getAngularElement(classElement, (e) => e is AngularFormatterElement); 546 getAngularElement(classElement, (e) => e is AngularFormatterElement);
555 JUnitTestCase.assertNotNull(filter); 547 expect(filter, isNotNull);
556 // verify 548 // verify
557 JUnitTestCase.assertEquals("myFilter", filter.name); 549 expect(filter.name, "myFilter");
558 JUnitTestCase.assertEquals( 550 expect(filter.nameOffset, AngularTest.findOffset(mainContent, "myFilter'"));
559 AngularTest.findOffset(mainContent, "myFilter'"),
560 filter.nameOffset);
561 } 551 }
562 552
563 void test_Formatter_missingName() { 553 void test_Formatter_missingName() {
564 String mainContent = _createAngularSource(r''' 554 String mainContent = _createAngularSource(r'''
565 @Formatter() 555 @Formatter()
566 class MyFilter { 556 class MyFilter {
567 call(p1, p2) {} 557 call(p1, p2) {}
568 }'''); 558 }''');
569 resolveMainSource(mainContent); 559 resolveMainSource(mainContent);
570 // has error 560 // has error
571 assertMainErrors([AngularCode.MISSING_NAME]); 561 assertMainErrors([AngularCode.MISSING_NAME]);
572 // no filter 562 // no filter
573 ClassElement classElement = mainUnitElement.getType("MyFilter"); 563 ClassElement classElement = mainUnitElement.getType("MyFilter");
574 AngularFormatterElement filter = 564 AngularFormatterElement filter =
575 getAngularElement(classElement, (e) => e is AngularFormatterElement); 565 getAngularElement(classElement, (e) => e is AngularFormatterElement);
576 JUnitTestCase.assertNull(filter); 566 expect(filter, isNull);
577 } 567 }
578 568
579 void test_NgComponent_bad_cannotParseSelector() { 569 void test_NgComponent_bad_cannotParseSelector() {
580 contextHelper.addSource("/my_template.html", ""); 570 contextHelper.addSource("/my_template.html", "");
581 contextHelper.addSource("/my_styles.css", ""); 571 contextHelper.addSource("/my_styles.css", "");
582 String mainContent = _createAngularSource(r''' 572 String mainContent = _createAngularSource(r'''
583 @Component(publishAs: 'ctrl', selector: '~myComp', 573 @Component(publishAs: 'ctrl', selector: '~myComp',
584 templateUrl: 'my_template.html', cssUrl: 'my_styles.css') 574 templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
585 class MyComponent { 575 class MyComponent {
586 }'''); 576 }''');
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 String mainContent = _createAngularSource(r''' 684 String mainContent = _createAngularSource(r'''
695 @Component(publishAs: 'ctrl', selector: 'myComp', 685 @Component(publishAs: 'ctrl', selector: 'myComp',
696 templateUrl: 'my_template.html'/*, cssUrl: 'my_styles.css'*/) 686 templateUrl: 'my_template.html'/*, cssUrl: 'my_styles.css'*/)
697 class MyComponent { 687 class MyComponent {
698 }'''); 688 }''');
699 resolveMainSource(mainContent); 689 resolveMainSource(mainContent);
700 // prepare AngularComponentElement 690 // prepare AngularComponentElement
701 ClassElement classElement = mainUnitElement.getType("MyComponent"); 691 ClassElement classElement = mainUnitElement.getType("MyComponent");
702 AngularComponentElement component = 692 AngularComponentElement component =
703 getAngularElement(classElement, (e) => e is AngularComponentElement); 693 getAngularElement(classElement, (e) => e is AngularComponentElement);
704 JUnitTestCase.assertNotNull(component); 694 expect(component, isNotNull);
705 // no CSS 695 // no CSS
706 JUnitTestCase.assertEquals(null, component.styleUri); 696 expect(component.styleUri, null);
707 JUnitTestCase.assertEquals(-1, component.styleUriOffset); 697 expect(component.styleUriOffset, -1);
708 } 698 }
709 699
710 void test_NgComponent_no_publishAs() { 700 void test_NgComponent_no_publishAs() {
711 contextHelper.addSource("/my_template.html", ""); 701 contextHelper.addSource("/my_template.html", "");
712 contextHelper.addSource("/my_styles.css", ""); 702 contextHelper.addSource("/my_styles.css", "");
713 String mainContent = _createAngularSource(r''' 703 String mainContent = _createAngularSource(r'''
714 @Component(/*publishAs: 'ctrl',*/ selector: 'myComp', 704 @Component(/*publishAs: 'ctrl',*/ selector: 'myComp',
715 templateUrl: 'my_template.html', cssUrl: 'my_styles.css') 705 templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
716 class MyComponent { 706 class MyComponent {
717 }'''); 707 }''');
718 resolveMainSource(mainContent); 708 resolveMainSource(mainContent);
719 // prepare AngularComponentElement 709 // prepare AngularComponentElement
720 ClassElement classElement = mainUnitElement.getType("MyComponent"); 710 ClassElement classElement = mainUnitElement.getType("MyComponent");
721 AngularComponentElement component = 711 AngularComponentElement component =
722 getAngularElement(classElement, (e) => e is AngularComponentElement); 712 getAngularElement(classElement, (e) => e is AngularComponentElement);
723 JUnitTestCase.assertNotNull(component); 713 expect(component, isNotNull);
724 // no name 714 // no name
725 JUnitTestCase.assertEquals(null, component.name); 715 expect(component.name, null);
726 JUnitTestCase.assertEquals(-1, component.nameOffset); 716 expect(component.nameOffset, -1);
727 } 717 }
728 718
729 void test_NgComponent_no_templateUrl() { 719 void test_NgComponent_no_templateUrl() {
730 contextHelper.addSource("/my_template.html", ""); 720 contextHelper.addSource("/my_template.html", "");
731 contextHelper.addSource("/my_styles.css", ""); 721 contextHelper.addSource("/my_styles.css", "");
732 String mainContent = _createAngularSource(r''' 722 String mainContent = _createAngularSource(r'''
733 @Component(publishAs: 'ctrl', selector: 'myComp', 723 @Component(publishAs: 'ctrl', selector: 'myComp',
734 /*templateUrl: 'my_template.html',*/ cssUrl: 'my_styles.css') 724 /*templateUrl: 'my_template.html',*/ cssUrl: 'my_styles.css')
735 class MyComponent { 725 class MyComponent {
736 }'''); 726 }''');
737 resolveMainSource(mainContent); 727 resolveMainSource(mainContent);
738 // prepare AngularComponentElement 728 // prepare AngularComponentElement
739 ClassElement classElement = mainUnitElement.getType("MyComponent"); 729 ClassElement classElement = mainUnitElement.getType("MyComponent");
740 AngularComponentElement component = 730 AngularComponentElement component =
741 getAngularElement(classElement, (e) => e is AngularComponentElement); 731 getAngularElement(classElement, (e) => e is AngularComponentElement);
742 JUnitTestCase.assertNotNull(component); 732 expect(component, isNotNull);
743 // no template 733 // no template
744 JUnitTestCase.assertEquals(null, component.templateUri); 734 expect(component.templateUri, null);
745 JUnitTestCase.assertEquals(null, component.templateSource); 735 expect(component.templateSource, null);
746 JUnitTestCase.assertEquals(-1, component.templateUriOffset); 736 expect(component.templateUriOffset, -1);
747 } 737 }
748 738
749 /** 739 /**
750 * https://code.google.com/p/dart/issues/detail?id=19023 740 * https://code.google.com/p/dart/issues/detail?id=19023
751 */ 741 */
752 void test_NgComponent_notAngular() { 742 void test_NgComponent_notAngular() {
753 contextHelper.addSource("/my_template.html", ""); 743 contextHelper.addSource("/my_template.html", "");
754 contextHelper.addSource("/my_styles.css", ""); 744 contextHelper.addSource("/my_styles.css", "");
755 String mainContent = r''' 745 String mainContent = r'''
756 class Component { 746 class Component {
(...skipping 22 matching lines...) Expand all
779 templateUrl: 'my_template.html', cssUrl: 'my_styles.css', 769 templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
780 map: const { 770 map: const {
781 'prop-a' : '@myPropA' 771 'prop-a' : '@myPropA'
782 }) 772 })
783 class MyComponent extends MySuper { 773 class MyComponent extends MySuper {
784 }''')); 774 }'''));
785 // prepare AngularComponentElement 775 // prepare AngularComponentElement
786 ClassElement classElement = mainUnitElement.getType("MyComponent"); 776 ClassElement classElement = mainUnitElement.getType("MyComponent");
787 AngularComponentElement component = 777 AngularComponentElement component =
788 getAngularElement(classElement, (e) => e is AngularComponentElement); 778 getAngularElement(classElement, (e) => e is AngularComponentElement);
789 JUnitTestCase.assertNotNull(component); 779 expect(component, isNotNull);
790 // verify 780 // verify
791 List<AngularPropertyElement> properties = component.properties; 781 List<AngularPropertyElement> properties = component.properties;
792 EngineTestCase.assertLength(1, properties); 782 EngineTestCase.assertLength(1, properties);
793 _assertProperty( 783 _assertProperty(
794 properties[0], 784 properties[0],
795 "prop-a", 785 "prop-a",
796 findMainOffset("prop-a' :"), 786 findMainOffset("prop-a' :"),
797 AngularPropertyKind.ATTR, 787 AngularPropertyKind.ATTR,
798 "myPropA", 788 "myPropA",
799 findMainOffset("myPropA'")); 789 findMainOffset("myPropA'"));
(...skipping 15 matching lines...) Expand all
815 var myPropC; 805 var myPropC;
816 @NgOneWayOneTime('prop-d') 806 @NgOneWayOneTime('prop-d')
817 var myPropD; 807 var myPropD;
818 @NgTwoWay('prop-e') 808 @NgTwoWay('prop-e')
819 var myPropE; 809 var myPropE;
820 }''')); 810 }'''));
821 // prepare AngularComponentElement 811 // prepare AngularComponentElement
822 ClassElement classElement = mainUnitElement.getType("MyComponent"); 812 ClassElement classElement = mainUnitElement.getType("MyComponent");
823 AngularComponentElement component = 813 AngularComponentElement component =
824 getAngularElement(classElement, (e) => e is AngularComponentElement); 814 getAngularElement(classElement, (e) => e is AngularComponentElement);
825 JUnitTestCase.assertNotNull(component); 815 expect(component, isNotNull);
826 // verify 816 // verify
827 List<AngularPropertyElement> properties = component.properties; 817 List<AngularPropertyElement> properties = component.properties;
828 EngineTestCase.assertLength(5, properties); 818 EngineTestCase.assertLength(5, properties);
829 _assertProperty( 819 _assertProperty(
830 properties[0], 820 properties[0],
831 "prop-a", 821 "prop-a",
832 findMainOffset("prop-a')"), 822 findMainOffset("prop-a')"),
833 AngularPropertyKind.ATTR, 823 AngularPropertyKind.ATTR,
834 "myPropA", 824 "myPropA",
835 -1); 825 -1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 var myPropA; 871 var myPropA;
882 var myPropB; 872 var myPropB;
883 var myPropC; 873 var myPropC;
884 var myPropD; 874 var myPropD;
885 var myPropE; 875 var myPropE;
886 }''')); 876 }'''));
887 // prepare AngularComponentElement 877 // prepare AngularComponentElement
888 ClassElement classElement = mainUnitElement.getType("MyComponent"); 878 ClassElement classElement = mainUnitElement.getType("MyComponent");
889 AngularComponentElement component = 879 AngularComponentElement component =
890 getAngularElement(classElement, (e) => e is AngularComponentElement); 880 getAngularElement(classElement, (e) => e is AngularComponentElement);
891 JUnitTestCase.assertNotNull(component); 881 expect(component, isNotNull);
892 // verify 882 // verify
893 List<AngularPropertyElement> properties = component.properties; 883 List<AngularPropertyElement> properties = component.properties;
894 EngineTestCase.assertLength(5, properties); 884 EngineTestCase.assertLength(5, properties);
895 _assertProperty( 885 _assertProperty(
896 properties[0], 886 properties[0],
897 "prop-a", 887 "prop-a",
898 findMainOffset("prop-a' :"), 888 findMainOffset("prop-a' :"),
899 AngularPropertyKind.ATTR, 889 AngularPropertyKind.ATTR,
900 "myPropA", 890 "myPropA",
901 findMainOffset("myPropA'")); 891 findMainOffset("myPropA'"));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 String mainContent = _createAngularSource(r''' 925 String mainContent = _createAngularSource(r'''
936 @Component(publishAs: 'ctrl', selector: 'myComp', 926 @Component(publishAs: 'ctrl', selector: 'myComp',
937 templateUrl: 'my_template.html', cssUrl: 'my_styles.css') 927 templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
938 class MyComponent { 928 class MyComponent {
939 }'''); 929 }''');
940 resolveMainSourceNoErrors(mainContent); 930 resolveMainSourceNoErrors(mainContent);
941 // prepare AngularComponentElement 931 // prepare AngularComponentElement
942 ClassElement classElement = mainUnitElement.getType("MyComponent"); 932 ClassElement classElement = mainUnitElement.getType("MyComponent");
943 AngularComponentElement component = 933 AngularComponentElement component =
944 getAngularElement(classElement, (e) => e is AngularComponentElement); 934 getAngularElement(classElement, (e) => e is AngularComponentElement);
945 JUnitTestCase.assertNotNull(component); 935 expect(component, isNotNull);
946 // verify 936 // verify
947 JUnitTestCase.assertEquals("ctrl", component.name); 937 expect(component.name, "ctrl");
948 JUnitTestCase.assertEquals( 938 expect(component.nameOffset, AngularTest.findOffset(mainContent, "ctrl'"));
949 AngularTest.findOffset(mainContent, "ctrl'"),
950 component.nameOffset);
951 _assertIsTagSelector(component.selector, "myComp"); 939 _assertIsTagSelector(component.selector, "myComp");
952 JUnitTestCase.assertEquals("my_template.html", component.templateUri); 940 expect(component.templateUri, "my_template.html");
953 JUnitTestCase.assertEquals( 941 expect(component.templateUriOffset, AngularTest.findOffset(mainContent, "my_ template.html'"));
954 AngularTest.findOffset(mainContent, "my_template.html'"), 942 expect(component.styleUri, "my_styles.css");
955 component.templateUriOffset); 943 expect(component.styleUriOffset, AngularTest.findOffset(mainContent, "my_sty les.css'"));
956 JUnitTestCase.assertEquals("my_styles.css", component.styleUri);
957 JUnitTestCase.assertEquals(
958 AngularTest.findOffset(mainContent, "my_styles.css'"),
959 component.styleUriOffset);
960 EngineTestCase.assertLength(0, component.properties); 944 EngineTestCase.assertLength(0, component.properties);
961 } 945 }
962 946
963 void test_NgComponent_scopeProperties() { 947 void test_NgComponent_scopeProperties() {
964 contextHelper.addSource("/my_template.html", ""); 948 contextHelper.addSource("/my_template.html", "");
965 contextHelper.addSource("/my_styles.css", ""); 949 contextHelper.addSource("/my_styles.css", "");
966 String mainContent = _createAngularSource(r''' 950 String mainContent = _createAngularSource(r'''
967 @Component(publishAs: 'ctrl', selector: 'myComp', 951 @Component(publishAs: 'ctrl', selector: 'myComp',
968 templateUrl: 'my_template.html', cssUrl: 'my_styles.css') 952 templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
969 class MyComponent { 953 class MyComponent {
970 MyComponent(Scope scope) { 954 MyComponent(Scope scope) {
971 scope.context['boolProp'] = true; 955 scope.context['boolProp'] = true;
972 scope.context['intProp'] = 42; 956 scope.context['intProp'] = 42;
973 scope.context['stringProp'] = 'foo'; 957 scope.context['stringProp'] = 'foo';
974 // duplicate is ignored 958 // duplicate is ignored
975 scope.context['boolProp'] = true; 959 scope.context['boolProp'] = true;
976 // LHS is not an IndexExpression 960 // LHS is not an IndexExpression
977 var v1; 961 var v1;
978 v1 = 1; 962 v1 = 1;
979 // LHS is not a Scope access 963 // LHS is not a Scope access
980 var v2; 964 var v2;
981 v2['name'] = 2; 965 v2['name'] = 2;
982 } 966 }
983 }'''); 967 }''');
984 resolveMainSourceNoErrors(mainContent); 968 resolveMainSourceNoErrors(mainContent);
985 // prepare AngularComponentElement 969 // prepare AngularComponentElement
986 ClassElement classElement = mainUnitElement.getType("MyComponent"); 970 ClassElement classElement = mainUnitElement.getType("MyComponent");
987 AngularComponentElement component = 971 AngularComponentElement component =
988 getAngularElement(classElement, (e) => e is AngularComponentElement); 972 getAngularElement(classElement, (e) => e is AngularComponentElement);
989 JUnitTestCase.assertNotNull(component); 973 expect(component, isNotNull);
990 // verify 974 // verify
991 List<AngularScopePropertyElement> scopeProperties = 975 List<AngularScopePropertyElement> scopeProperties =
992 component.scopeProperties; 976 component.scopeProperties;
993 EngineTestCase.assertLength(3, scopeProperties); 977 EngineTestCase.assertLength(3, scopeProperties);
994 { 978 {
995 AngularScopePropertyElement property = scopeProperties[0]; 979 AngularScopePropertyElement property = scopeProperties[0];
996 JUnitTestCase.assertSame(property, findMainElement2("boolProp")); 980 expect(findMainElement2("boolProp"), same(property));
997 JUnitTestCase.assertEquals("boolProp", property.name); 981 expect(property.name, "boolProp");
998 JUnitTestCase.assertEquals( 982 expect(property.nameOffset, AngularTest.findOffset(mainContent, "boolProp' "));
999 AngularTest.findOffset(mainContent, "boolProp'"), 983 expect(property.type.name, "bool");
1000 property.nameOffset);
1001 JUnitTestCase.assertEquals("bool", property.type.name);
1002 } 984 }
1003 { 985 {
1004 AngularScopePropertyElement property = scopeProperties[1]; 986 AngularScopePropertyElement property = scopeProperties[1];
1005 JUnitTestCase.assertSame(property, findMainElement2("intProp")); 987 expect(findMainElement2("intProp"), same(property));
1006 JUnitTestCase.assertEquals("intProp", property.name); 988 expect(property.name, "intProp");
1007 JUnitTestCase.assertEquals( 989 expect(property.nameOffset, AngularTest.findOffset(mainContent, "intProp'" ));
1008 AngularTest.findOffset(mainContent, "intProp'"), 990 expect(property.type.name, "int");
1009 property.nameOffset);
1010 JUnitTestCase.assertEquals("int", property.type.name);
1011 } 991 }
1012 { 992 {
1013 AngularScopePropertyElement property = scopeProperties[2]; 993 AngularScopePropertyElement property = scopeProperties[2];
1014 JUnitTestCase.assertSame(property, findMainElement2("stringProp")); 994 expect(findMainElement2("stringProp"), same(property));
1015 JUnitTestCase.assertEquals("stringProp", property.name); 995 expect(property.name, "stringProp");
1016 JUnitTestCase.assertEquals( 996 expect(property.nameOffset, AngularTest.findOffset(mainContent, "stringPro p'"));
1017 AngularTest.findOffset(mainContent, "stringProp'"), 997 expect(property.type.name, "String");
1018 property.nameOffset);
1019 JUnitTestCase.assertEquals("String", property.type.name);
1020 } 998 }
1021 } 999 }
1022 1000
1023 void test_NgController() { 1001 void test_NgController() {
1024 String mainContent = _createAngularSource(r''' 1002 String mainContent = _createAngularSource(r'''
1025 @Controller(publishAs: 'ctrl', selector: '[myApp]') 1003 @Controller(publishAs: 'ctrl', selector: '[myApp]')
1026 class MyController { 1004 class MyController {
1027 }'''); 1005 }''');
1028 resolveMainSourceNoErrors(mainContent); 1006 resolveMainSourceNoErrors(mainContent);
1029 // prepare AngularControllerElement 1007 // prepare AngularControllerElement
1030 ClassElement classElement = mainUnitElement.getType("MyController"); 1008 ClassElement classElement = mainUnitElement.getType("MyController");
1031 AngularControllerElement controller = 1009 AngularControllerElement controller =
1032 getAngularElement(classElement, (e) => e is AngularControllerElement); 1010 getAngularElement(classElement, (e) => e is AngularControllerElement);
1033 JUnitTestCase.assertNotNull(controller); 1011 expect(controller, isNotNull);
1034 // verify 1012 // verify
1035 JUnitTestCase.assertEquals("ctrl", controller.name); 1013 expect(controller.name, "ctrl");
1036 JUnitTestCase.assertEquals( 1014 expect(controller.nameOffset, AngularTest.findOffset(mainContent, "ctrl'"));
1037 AngularTest.findOffset(mainContent, "ctrl'"),
1038 controller.nameOffset);
1039 _assertHasAttributeSelector(controller.selector, "myApp"); 1015 _assertHasAttributeSelector(controller.selector, "myApp");
1040 } 1016 }
1041 1017
1042 void test_NgController_cannotParseSelector() { 1018 void test_NgController_cannotParseSelector() {
1043 String mainContent = _createAngularSource(r''' 1019 String mainContent = _createAngularSource(r'''
1044 @Controller(publishAs: 'ctrl', selector: '~unknown') 1020 @Controller(publishAs: 'ctrl', selector: '~unknown')
1045 class MyController { 1021 class MyController {
1046 }'''); 1022 }''');
1047 resolveMainSource(mainContent); 1023 resolveMainSource(mainContent);
1048 // has error 1024 // has error
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 String mainContent = r''' 1058 String mainContent = r'''
1083 const MY_ANNOTATION = null; 1059 const MY_ANNOTATION = null;
1084 @MY_ANNOTATION() 1060 @MY_ANNOTATION()
1085 class MyFilter { 1061 class MyFilter {
1086 }'''; 1062 }''';
1087 resolveMainSource(mainContent); 1063 resolveMainSource(mainContent);
1088 // prepare AngularFilterElement 1064 // prepare AngularFilterElement
1089 ClassElement classElement = mainUnitElement.getType("MyFilter"); 1065 ClassElement classElement = mainUnitElement.getType("MyFilter");
1090 AngularFormatterElement filter = 1066 AngularFormatterElement filter =
1091 getAngularElement(classElement, (e) => e is AngularFormatterElement); 1067 getAngularElement(classElement, (e) => e is AngularFormatterElement);
1092 JUnitTestCase.assertNull(filter); 1068 expect(filter, isNull);
1093 } 1069 }
1094 1070
1095 void test_getElement_SimpleStringLiteral_withToolkitElement() { 1071 void test_getElement_SimpleStringLiteral_withToolkitElement() {
1096 SimpleStringLiteral literal = AstFactory.string2("foo"); 1072 SimpleStringLiteral literal = AstFactory.string2("foo");
1097 Element element = new AngularScopePropertyElementImpl("foo", 0, null); 1073 Element element = new AngularScopePropertyElementImpl("foo", 0, null);
1098 literal.toolkitElement = element; 1074 literal.toolkitElement = element;
1099 JUnitTestCase.assertSame( 1075 expect(AngularCompilationUnitBuilder.getElement(literal, -1), same(element)) ;
1100 element,
1101 AngularCompilationUnitBuilder.getElement(literal, -1));
1102 } 1076 }
1103 1077
1104 void test_getElement_component_name() { 1078 void test_getElement_component_name() {
1105 resolveMainSource( 1079 resolveMainSource(
1106 _createAngularSource(r''' 1080 _createAngularSource(r'''
1107 @Component(publishAs: 'ctrl', selector: 'myComp', 1081 @Component(publishAs: 'ctrl', selector: 'myComp',
1108 templateUrl: 'my_template.html', cssUrl: 'my_styles.css') 1082 templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
1109 class MyComponent {}''')); 1083 class MyComponent {}'''));
1110 SimpleStringLiteral node = 1084 SimpleStringLiteral node =
1111 _findMainNode("ctrl'", (n) => n is SimpleStringLiteral); 1085 _findMainNode("ctrl'", (n) => n is SimpleStringLiteral);
(...skipping 14 matching lines...) Expand all
1126 class MyComponent { 1100 class MyComponent {
1127 @NgOneWay('prop') 1101 @NgOneWay('prop')
1128 var field; 1102 var field;
1129 }''')); 1103 }'''));
1130 // prepare node 1104 // prepare node
1131 SimpleStringLiteral node = 1105 SimpleStringLiteral node =
1132 _findMainNode("prop'", (n) => n is SimpleStringLiteral); 1106 _findMainNode("prop'", (n) => n is SimpleStringLiteral);
1133 int offset = node.offset; 1107 int offset = node.offset;
1134 // prepare Element 1108 // prepare Element
1135 Element element = AngularCompilationUnitBuilder.getElement(node, offset); 1109 Element element = AngularCompilationUnitBuilder.getElement(node, offset);
1136 JUnitTestCase.assertNotNull(element); 1110 expect(element, isNotNull);
1137 // check AngularPropertyElement 1111 // check AngularPropertyElement
1138 AngularPropertyElement property = element as AngularPropertyElement; 1112 AngularPropertyElement property = element as AngularPropertyElement;
1139 JUnitTestCase.assertEquals("prop", property.name); 1113 expect(property.name, "prop");
1140 } 1114 }
1141 1115
1142 void test_getElement_component_property_fromMap() { 1116 void test_getElement_component_property_fromMap() {
1143 resolveMainSource( 1117 resolveMainSource(
1144 _createAngularSource(r''' 1118 _createAngularSource(r'''
1145 @Component(publishAs: 'ctrl', selector: 'myComp', 1119 @Component(publishAs: 'ctrl', selector: 'myComp',
1146 templateUrl: 'my_template.html', cssUrl: 'my_styles.css', 1120 templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
1147 map: const { 1121 map: const {
1148 'prop' : '@field', 1122 'prop' : '@field',
1149 }) 1123 })
1150 class MyComponent { 1124 class MyComponent {
1151 var field; 1125 var field;
1152 }''')); 1126 }'''));
1153 // AngularPropertyElement 1127 // AngularPropertyElement
1154 { 1128 {
1155 SimpleStringLiteral node = 1129 SimpleStringLiteral node =
1156 _findMainNode("prop'", (n) => n is SimpleStringLiteral); 1130 _findMainNode("prop'", (n) => n is SimpleStringLiteral);
1157 int offset = node.offset; 1131 int offset = node.offset;
1158 // prepare Element 1132 // prepare Element
1159 Element element = AngularCompilationUnitBuilder.getElement(node, offset); 1133 Element element = AngularCompilationUnitBuilder.getElement(node, offset);
1160 JUnitTestCase.assertNotNull(element); 1134 expect(element, isNotNull);
1161 // check AngularPropertyElement 1135 // check AngularPropertyElement
1162 AngularPropertyElement property = element as AngularPropertyElement; 1136 AngularPropertyElement property = element as AngularPropertyElement;
1163 JUnitTestCase.assertEquals("prop", property.name); 1137 expect(property.name, "prop");
1164 } 1138 }
1165 // FieldElement 1139 // FieldElement
1166 { 1140 {
1167 SimpleStringLiteral node = 1141 SimpleStringLiteral node =
1168 _findMainNode("@field'", (n) => n is SimpleStringLiteral); 1142 _findMainNode("@field'", (n) => n is SimpleStringLiteral);
1169 int offset = node.offset; 1143 int offset = node.offset;
1170 // prepare Element 1144 // prepare Element
1171 Element element = AngularCompilationUnitBuilder.getElement(node, offset); 1145 Element element = AngularCompilationUnitBuilder.getElement(node, offset);
1172 JUnitTestCase.assertNotNull(element); 1146 expect(element, isNotNull);
1173 // check FieldElement 1147 // check FieldElement
1174 FieldElement field = element as FieldElement; 1148 FieldElement field = element as FieldElement;
1175 JUnitTestCase.assertEquals("field", field.name); 1149 expect(field.name, "field");
1176 } 1150 }
1177 } 1151 }
1178 1152
1179 void test_getElement_component_selector() { 1153 void test_getElement_component_selector() {
1180 resolveMainSource( 1154 resolveMainSource(
1181 _createAngularSource(r''' 1155 _createAngularSource(r'''
1182 @Component(publishAs: 'ctrl', selector: 'myComp', 1156 @Component(publishAs: 'ctrl', selector: 'myComp',
1183 templateUrl: 'my_template.html', cssUrl: 'my_styles.css') 1157 templateUrl: 'my_template.html', cssUrl: 'my_styles.css')
1184 class MyComponent {}''')); 1158 class MyComponent {}'''));
1185 SimpleStringLiteral node = 1159 SimpleStringLiteral node =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 }) 1193 })
1220 class MyDirective { 1194 class MyDirective {
1221 set field(value) {} 1195 set field(value) {}
1222 }''')); 1196 }'''));
1223 // prepare node 1197 // prepare node
1224 SimpleStringLiteral node = 1198 SimpleStringLiteral node =
1225 _findMainNode("my-dir'", (n) => n is SimpleStringLiteral); 1199 _findMainNode("my-dir'", (n) => n is SimpleStringLiteral);
1226 int offset = node.offset; 1200 int offset = node.offset;
1227 // prepare Element 1201 // prepare Element
1228 Element element = AngularCompilationUnitBuilder.getElement(node, offset); 1202 Element element = AngularCompilationUnitBuilder.getElement(node, offset);
1229 JUnitTestCase.assertNotNull(element); 1203 expect(element, isNotNull);
1230 // check AngularPropertyElement 1204 // check AngularPropertyElement
1231 AngularPropertyElement property = element as AngularPropertyElement; 1205 AngularPropertyElement property = element as AngularPropertyElement;
1232 JUnitTestCase.assertEquals("my-dir", property.name); 1206 expect(property.name, "my-dir");
1233 } 1207 }
1234 1208
1235 void test_getElement_directive_selector() { 1209 void test_getElement_directive_selector() {
1236 resolveMainSource( 1210 resolveMainSource(
1237 _createAngularSource(r''' 1211 _createAngularSource(r'''
1238 @Decorator(selector: '[my-dir]') 1212 @Decorator(selector: '[my-dir]')
1239 class MyDirective {}''')); 1213 class MyDirective {}'''));
1240 SimpleStringLiteral node = 1214 SimpleStringLiteral node =
1241 _findMainNode("my-dir]'", (n) => n is SimpleStringLiteral); 1215 _findMainNode("my-dir]'", (n) => n is SimpleStringLiteral);
1242 int offset = node.offset; 1216 int offset = node.offset;
(...skipping 21 matching lines...) Expand all
1264 (obj) => obj is AngularFormatterElement, 1238 (obj) => obj is AngularFormatterElement,
1265 AngularFormatterElement, 1239 AngularFormatterElement,
1266 element); 1240 element);
1267 } 1241 }
1268 1242
1269 void test_getElement_noClassDeclaration() { 1243 void test_getElement_noClassDeclaration() {
1270 resolveMainSource("var foo = 'bar';"); 1244 resolveMainSource("var foo = 'bar';");
1271 SimpleStringLiteral node = 1245 SimpleStringLiteral node =
1272 _findMainNode("bar'", (n) => n is SimpleStringLiteral); 1246 _findMainNode("bar'", (n) => n is SimpleStringLiteral);
1273 Element element = AngularCompilationUnitBuilder.getElement(node, 0); 1247 Element element = AngularCompilationUnitBuilder.getElement(node, 0);
1274 JUnitTestCase.assertNull(element); 1248 expect(element, isNull);
1275 } 1249 }
1276 1250
1277 void test_getElement_noClassElement() { 1251 void test_getElement_noClassElement() {
1278 resolveMainSource(r''' 1252 resolveMainSource(r'''
1279 class A { 1253 class A {
1280 const A(p); 1254 const A(p);
1281 } 1255 }
1282 1256
1283 @A('bar') 1257 @A('bar')
1284 class B {}'''); 1258 class B {}''');
1285 SimpleStringLiteral node = 1259 SimpleStringLiteral node =
1286 _findMainNode("bar'", (n) => n is SimpleStringLiteral); 1260 _findMainNode("bar'", (n) => n is SimpleStringLiteral);
1287 // reset B element 1261 // reset B element
1288 ClassDeclaration classDeclaration = 1262 ClassDeclaration classDeclaration =
1289 node.getAncestor((node) => node is ClassDeclaration); 1263 node.getAncestor((node) => node is ClassDeclaration);
1290 classDeclaration.name.staticElement = null; 1264 classDeclaration.name.staticElement = null;
1291 // class is not resolved - no element 1265 // class is not resolved - no element
1292 Element element = AngularCompilationUnitBuilder.getElement(node, 0); 1266 Element element = AngularCompilationUnitBuilder.getElement(node, 0);
1293 JUnitTestCase.assertNull(element); 1267 expect(element, isNull);
1294 } 1268 }
1295 1269
1296 void test_getElement_noNode() { 1270 void test_getElement_noNode() {
1297 Element element = AngularCompilationUnitBuilder.getElement(null, 0); 1271 Element element = AngularCompilationUnitBuilder.getElement(null, 0);
1298 JUnitTestCase.assertNull(element); 1272 expect(element, isNull);
1299 } 1273 }
1300 1274
1301 void test_getElement_notFound() { 1275 void test_getElement_notFound() {
1302 resolveMainSource(r''' 1276 resolveMainSource(r'''
1303 class MyComponent { 1277 class MyComponent {
1304 var str = 'some string'; 1278 var str = 'some string';
1305 }'''); 1279 }''');
1306 // prepare node 1280 // prepare node
1307 SimpleStringLiteral node = 1281 SimpleStringLiteral node =
1308 _findMainNode("some string'", (n) => n is SimpleStringLiteral); 1282 _findMainNode("some string'", (n) => n is SimpleStringLiteral);
1309 int offset = node.offset; 1283 int offset = node.offset;
1310 // no Element 1284 // no Element
1311 Element element = AngularCompilationUnitBuilder.getElement(node, offset); 1285 Element element = AngularCompilationUnitBuilder.getElement(node, offset);
1312 JUnitTestCase.assertNull(element); 1286 expect(element, isNull);
1313 } 1287 }
1314 1288
1315 void test_parseSelector_hasAttribute() { 1289 void test_parseSelector_hasAttribute() {
1316 AngularSelectorElement selector = 1290 AngularSelectorElement selector =
1317 AngularCompilationUnitBuilder.parseSelector(42, "[name]"); 1291 AngularCompilationUnitBuilder.parseSelector(42, "[name]");
1318 _assertHasAttributeSelector(selector, "name"); 1292 _assertHasAttributeSelector(selector, "name");
1319 JUnitTestCase.assertEquals(42 + 1, selector.nameOffset); 1293 expect(selector.nameOffset, 42 + 1);
1320 } 1294 }
1321 1295
1322 void test_parseSelector_hasClass() { 1296 void test_parseSelector_hasClass() {
1323 AngularSelectorElement selector = 1297 AngularSelectorElement selector =
1324 AngularCompilationUnitBuilder.parseSelector(42, ".my-class"); 1298 AngularCompilationUnitBuilder.parseSelector(42, ".my-class");
1325 AngularHasClassSelectorElementImpl classSelector = 1299 AngularHasClassSelectorElementImpl classSelector =
1326 selector as AngularHasClassSelectorElementImpl; 1300 selector as AngularHasClassSelectorElementImpl;
1327 JUnitTestCase.assertEquals("my-class", classSelector.name); 1301 expect(classSelector.name, "my-class");
1328 JUnitTestCase.assertEquals(".my-class", classSelector.toString()); 1302 expect(classSelector.toString(), ".my-class");
1329 JUnitTestCase.assertEquals(42 + 1, selector.nameOffset); 1303 expect(selector.nameOffset, 42 + 1);
1330 // test apply() 1304 // test apply()
1331 { 1305 {
1332 ht.XmlTagNode node = 1306 ht.XmlTagNode node =
1333 HtmlFactory.tagNode("div", [HtmlFactory.attribute("class", "one two")] ); 1307 HtmlFactory.tagNode("div", [HtmlFactory.attribute("class", "one two")] );
1334 JUnitTestCase.assertFalse(classSelector.apply(node)); 1308 expect(classSelector.apply(node), isFalse);
1335 } 1309 }
1336 { 1310 {
1337 ht.XmlTagNode node = HtmlFactory.tagNode( 1311 ht.XmlTagNode node = HtmlFactory.tagNode(
1338 "div", 1312 "div",
1339 [HtmlFactory.attribute("class", "one my-class two")]); 1313 [HtmlFactory.attribute("class", "one my-class two")]);
1340 JUnitTestCase.assertTrue(classSelector.apply(node)); 1314 expect(classSelector.apply(node), isTrue);
1341 } 1315 }
1342 } 1316 }
1343 1317
1344 void test_parseSelector_isTag() { 1318 void test_parseSelector_isTag() {
1345 AngularSelectorElement selector = 1319 AngularSelectorElement selector =
1346 AngularCompilationUnitBuilder.parseSelector(42, "name"); 1320 AngularCompilationUnitBuilder.parseSelector(42, "name");
1347 _assertIsTagSelector(selector, "name"); 1321 _assertIsTagSelector(selector, "name");
1348 JUnitTestCase.assertEquals(42, selector.nameOffset); 1322 expect(selector.nameOffset, 42);
1349 } 1323 }
1350 1324
1351 void test_parseSelector_isTag_hasAttribute() { 1325 void test_parseSelector_isTag_hasAttribute() {
1352 AngularSelectorElement selector = 1326 AngularSelectorElement selector =
1353 AngularCompilationUnitBuilder.parseSelector(42, "tag[attr]"); 1327 AngularCompilationUnitBuilder.parseSelector(42, "tag[attr]");
1354 EngineTestCase.assertInstanceOf( 1328 EngineTestCase.assertInstanceOf(
1355 (obj) => obj is IsTagHasAttributeSelectorElementImpl, 1329 (obj) => obj is IsTagHasAttributeSelectorElementImpl,
1356 IsTagHasAttributeSelectorElementImpl, 1330 IsTagHasAttributeSelectorElementImpl,
1357 selector); 1331 selector);
1358 JUnitTestCase.assertEquals("tag[attr]", selector.name); 1332 expect(selector.name, "tag[attr]");
1359 JUnitTestCase.assertEquals(-1, selector.nameOffset); 1333 expect(selector.nameOffset, -1);
1360 JUnitTestCase.assertEquals( 1334 expect((selector as IsTagHasAttributeSelectorElementImpl).tagName, "tag");
1361 "tag", 1335 expect((selector as IsTagHasAttributeSelectorElementImpl).attributeName, "at tr");
1362 (selector as IsTagHasAttributeSelectorElementImpl).tagName);
1363 JUnitTestCase.assertEquals(
1364 "attr",
1365 (selector as IsTagHasAttributeSelectorElementImpl).attributeName);
1366 } 1336 }
1367 1337
1368 void test_parseSelector_unknown() { 1338 void test_parseSelector_unknown() {
1369 AngularSelectorElement selector = 1339 AngularSelectorElement selector =
1370 AngularCompilationUnitBuilder.parseSelector(0, "~unknown"); 1340 AngularCompilationUnitBuilder.parseSelector(0, "~unknown");
1371 JUnitTestCase.assertNull(selector); 1341 expect(selector, isNull);
1372 } 1342 }
1373 1343
1374 void test_view() { 1344 void test_view() {
1375 contextHelper.addSource("/wrong.html", ""); 1345 contextHelper.addSource("/wrong.html", "");
1376 contextHelper.addSource("/my_templateA.html", ""); 1346 contextHelper.addSource("/my_templateA.html", "");
1377 contextHelper.addSource("/my_templateB.html", ""); 1347 contextHelper.addSource("/my_templateB.html", "");
1378 String mainContent = _createAngularSource(r''' 1348 String mainContent = _createAngularSource(r'''
1379 class MyRouteInitializer { 1349 class MyRouteInitializer {
1380 init(ViewFactory view, foo) { 1350 init(ViewFactory view, foo) {
1381 foo.view('wrong.html'); // has target 1351 foo.view('wrong.html'); // has target
1382 foo(); // less than one argument 1352 foo(); // less than one argument
1383 foo('wrong.html', 'bar'); // more than one argument 1353 foo('wrong.html', 'bar'); // more than one argument
1384 foo('wrong' + '.html'); // not literal 1354 foo('wrong' + '.html'); // not literal
1385 foo('wrong.html'); // not ViewFactory 1355 foo('wrong.html'); // not ViewFactory
1386 view('my_templateA.html'); 1356 view('my_templateA.html');
1387 view('my_templateB.html'); 1357 view('my_templateB.html');
1388 } 1358 }
1389 }'''); 1359 }''');
1390 resolveMainSourceNoErrors(mainContent); 1360 resolveMainSourceNoErrors(mainContent);
1391 // prepare AngularViewElement(s) 1361 // prepare AngularViewElement(s)
1392 List<AngularViewElement> views = mainUnitElement.angularViews; 1362 List<AngularViewElement> views = mainUnitElement.angularViews;
1393 EngineTestCase.assertLength(2, views); 1363 EngineTestCase.assertLength(2, views);
1394 { 1364 {
1395 AngularViewElement view = views[0]; 1365 AngularViewElement view = views[0];
1396 JUnitTestCase.assertEquals("my_templateA.html", view.templateUri); 1366 expect(view.templateUri, "my_templateA.html");
1397 JUnitTestCase.assertEquals(null, view.name); 1367 expect(view.name, null);
1398 JUnitTestCase.assertEquals(-1, view.nameOffset); 1368 expect(view.nameOffset, -1);
1399 JUnitTestCase.assertEquals( 1369 expect(view.templateUriOffset, AngularTest.findOffset(mainContent, "my_tem plateA.html'"));
1400 AngularTest.findOffset(mainContent, "my_templateA.html'"),
1401 view.templateUriOffset);
1402 } 1370 }
1403 { 1371 {
1404 AngularViewElement view = views[1]; 1372 AngularViewElement view = views[1];
1405 JUnitTestCase.assertEquals("my_templateB.html", view.templateUri); 1373 expect(view.templateUri, "my_templateB.html");
1406 JUnitTestCase.assertEquals(null, view.name); 1374 expect(view.name, null);
1407 JUnitTestCase.assertEquals(-1, view.nameOffset); 1375 expect(view.nameOffset, -1);
1408 JUnitTestCase.assertEquals( 1376 expect(view.templateUriOffset, AngularTest.findOffset(mainContent, "my_tem plateB.html'"));
1409 AngularTest.findOffset(mainContent, "my_templateB.html'"),
1410 view.templateUriOffset);
1411 } 1377 }
1412 } 1378 }
1413 1379
1414 void _assertProperty(AngularPropertyElement property, String expectedName, 1380 void _assertProperty(AngularPropertyElement property, String expectedName,
1415 int expectedNameOffset, AngularPropertyKind expectedKind, 1381 int expectedNameOffset, AngularPropertyKind expectedKind,
1416 String expectedFieldName, int expectedFieldOffset) { 1382 String expectedFieldName, int expectedFieldOffset) {
1417 JUnitTestCase.assertEquals(expectedName, property.name); 1383 expect(property.name, expectedName);
1418 JUnitTestCase.assertEquals(expectedNameOffset, property.nameOffset); 1384 expect(property.nameOffset, expectedNameOffset);
1419 JUnitTestCase.assertSame(expectedKind, property.propertyKind); 1385 expect(property.propertyKind, same(expectedKind));
1420 JUnitTestCase.assertEquals(expectedFieldName, property.field.name); 1386 expect(property.field.name, expectedFieldName);
1421 JUnitTestCase.assertEquals(expectedFieldOffset, property.fieldNameOffset); 1387 expect(property.fieldNameOffset, expectedFieldOffset);
1422 } 1388 }
1423 1389
1424 /** 1390 /**
1425 * Find [AstNode] of the given type in [mainUnit]. 1391 * Find [AstNode] of the given type in [mainUnit].
1426 */ 1392 */
1427 AstNode _findMainNode(String search, Predicate<AstNode> predicate) { 1393 AstNode _findMainNode(String search, Predicate<AstNode> predicate) {
1428 return EngineTestCase.findNode(mainUnit, mainContent, search, predicate); 1394 return EngineTestCase.findNode(mainUnit, mainContent, search, predicate);
1429 } 1395 }
1430 1396
1431 static AngularElement getAngularElement(Element element, 1397 static AngularElement getAngularElement(Element element,
(...skipping 16 matching lines...) Expand all
1448 } 1414 }
1449 return null; 1415 return null;
1450 } 1416 }
1451 1417
1452 static void _assertHasAttributeSelector(AngularSelectorElement selector, 1418 static void _assertHasAttributeSelector(AngularSelectorElement selector,
1453 String name) { 1419 String name) {
1454 EngineTestCase.assertInstanceOf( 1420 EngineTestCase.assertInstanceOf(
1455 (obj) => obj is HasAttributeSelectorElementImpl, 1421 (obj) => obj is HasAttributeSelectorElementImpl,
1456 HasAttributeSelectorElementImpl, 1422 HasAttributeSelectorElementImpl,
1457 selector); 1423 selector);
1458 JUnitTestCase.assertEquals( 1424 expect((selector as HasAttributeSelectorElementImpl).name, name);
1459 name,
1460 (selector as HasAttributeSelectorElementImpl).name);
1461 } 1425 }
1462 1426
1463 static void _assertIsTagSelector(AngularSelectorElement selector, 1427 static void _assertIsTagSelector(AngularSelectorElement selector,
1464 String name) { 1428 String name) {
1465 EngineTestCase.assertInstanceOf( 1429 EngineTestCase.assertInstanceOf(
1466 (obj) => obj is AngularTagSelectorElementImpl, 1430 (obj) => obj is AngularTagSelectorElementImpl,
1467 AngularTagSelectorElementImpl, 1431 AngularTagSelectorElementImpl,
1468 selector); 1432 selector);
1469 JUnitTestCase.assertEquals( 1433 expect((selector as AngularTagSelectorElementImpl).name, name);
1470 name,
1471 (selector as AngularTagSelectorElementImpl).name);
1472 } 1434 }
1473 1435
1474 static String _createAngularSource(String code) { 1436 static String _createAngularSource(String code) {
1475 return "import 'angular.dart';\n" + code; 1437 return "import 'angular.dart';\n" + code;
1476 } 1438 }
1477 } 1439 }
1478 1440
1479 1441
1480 class AngularHtmlUnitResolverTest extends AngularTest { 1442 class AngularHtmlUnitResolverTest extends AngularTest {
1481 void test_NgComponent_resolveTemplateFile() { 1443 void test_NgComponent_resolveTemplateFile() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 library main; 1486 library main;
1525 import 'my_module.dart';'''); 1487 import 'my_module.dart';''');
1526 _resolveIndexNoErrors( 1488 _resolveIndexNoErrors(
1527 AngularTest.createHtmlWithMyController("<myComponent/>")); 1489 AngularTest.createHtmlWithMyController("<myComponent/>"));
1528 // "myComponent" tag was resolved 1490 // "myComponent" tag was resolved
1529 { 1491 {
1530 ht.XmlTagNode tagNode = 1492 ht.XmlTagNode tagNode =
1531 ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent")); 1493 ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent"));
1532 AngularSelectorElement tagElement = 1494 AngularSelectorElement tagElement =
1533 tagNode.element as AngularSelectorElement; 1495 tagNode.element as AngularSelectorElement;
1534 JUnitTestCase.assertNotNull(tagElement); 1496 expect(tagElement, isNotNull);
1535 JUnitTestCase.assertEquals("myComponent", tagElement.name); 1497 expect(tagElement.name, "myComponent");
1536 } 1498 }
1537 // replace "myComponent" with "myComponent2" 1499 // replace "myComponent" with "myComponent2"
1538 // in my_component.dart and index.html 1500 // in my_component.dart and index.html
1539 { 1501 {
1540 context.setContents( 1502 context.setContents(
1541 componentSource, 1503 componentSource,
1542 _getSourceContent(componentSource).replaceAll("myComponent", "myCompon ent2")); 1504 _getSourceContent(componentSource).replaceAll("myComponent", "myCompon ent2"));
1543 indexContent = 1505 indexContent =
1544 _getSourceContent(indexSource).replaceAll("myComponent", "myComponent2 "); 1506 _getSourceContent(indexSource).replaceAll("myComponent", "myComponent2 ");
1545 context.setContents(indexSource, indexContent); 1507 context.setContents(indexSource, indexContent);
1546 } 1508 }
1547 contextHelper.runTasks(); 1509 contextHelper.runTasks();
1548 resolveIndex(); 1510 resolveIndex();
1549 // "myComponent2" tag should be resolved 1511 // "myComponent2" tag should be resolved
1550 { 1512 {
1551 ht.XmlTagNode tagNode = 1513 ht.XmlTagNode tagNode =
1552 ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent2")); 1514 ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent2"));
1553 AngularSelectorElement tagElement = 1515 AngularSelectorElement tagElement =
1554 tagNode.element as AngularSelectorElement; 1516 tagNode.element as AngularSelectorElement;
1555 JUnitTestCase.assertNotNull(tagElement); 1517 expect(tagElement, isNotNull);
1556 JUnitTestCase.assertEquals("myComponent2", tagElement.name); 1518 expect(tagElement.name, "myComponent2");
1557 } 1519 }
1558 } 1520 }
1559 1521
1560 void test_NgComponent_use_resolveAttributes() { 1522 void test_NgComponent_use_resolveAttributes() {
1561 contextHelper.addSource( 1523 contextHelper.addSource(
1562 "/my_template.html", 1524 "/my_template.html",
1563 r''' 1525 r'''
1564 <div> 1526 <div>
1565 {{ctrl.field}} 1527 {{ctrl.field}}
1566 </div>'''); 1528 </div>''');
1567 addMainSource(r''' 1529 addMainSource(r'''
1568 1530
1569 import 'angular.dart'; 1531 import 'angular.dart';
1570 1532
1571 @Component( 1533 @Component(
1572 templateUrl: 'my_template.html', cssUrl: 'my_styles.css', 1534 templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
1573 publishAs: 'ctrl', 1535 publishAs: 'ctrl',
1574 selector: 'myComponent', // selector 1536 selector: 'myComponent', // selector
1575 map: const {'attrA' : '=>setA', 'attrB' : '@setB'}) 1537 map: const {'attrA' : '=>setA', 'attrB' : '@setB'})
1576 class MyComponent { 1538 class MyComponent {
1577 set setA(value) {} 1539 set setA(value) {}
1578 set setB(value) {} 1540 set setB(value) {}
1579 }'''); 1541 }''');
1580 _resolveIndexNoErrors( 1542 _resolveIndexNoErrors(
1581 AngularTest.createHtmlWithMyController(r''' 1543 AngularTest.createHtmlWithMyController(r'''
1582 <input type='text' ng-model='someModel'/> 1544 <input type='text' ng-model='someModel'/>
1583 <myComponent attrA='someModel' attrB='bbb'/>''')); 1545 <myComponent attrA='someModel' attrB='bbb'/>'''));
1584 // "attrA" attribute expression was resolved 1546 // "attrA" attribute expression was resolved
1585 JUnitTestCase.assertNotNull(findIdentifier("someModel")); 1547 expect(findIdentifier("someModel"), isNotNull);
1586 // "myComponent" tag was resolved 1548 // "myComponent" tag was resolved
1587 ht.XmlTagNode tagNode = 1549 ht.XmlTagNode tagNode =
1588 ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent")); 1550 ht.HtmlUnitUtils.getTagNode(indexUnit, findOffset2("myComponent"));
1589 AngularSelectorElement tagElement = 1551 AngularSelectorElement tagElement =
1590 tagNode.element as AngularSelectorElement; 1552 tagNode.element as AngularSelectorElement;
1591 JUnitTestCase.assertNotNull(tagElement); 1553 expect(tagElement, isNotNull);
1592 JUnitTestCase.assertEquals("myComponent", tagElement.name); 1554 expect(tagElement.name, "myComponent");
1593 JUnitTestCase.assertEquals( 1555 expect(tagElement.nameOffset, findMainOffset("myComponent', // selector"));
1594 findMainOffset("myComponent', // selector"),
1595 tagElement.nameOffset);
1596 // "attrA" attribute was resolved 1556 // "attrA" attribute was resolved
1597 { 1557 {
1598 ht.XmlAttributeNode node = 1558 ht.XmlAttributeNode node =
1599 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("attrA='")); 1559 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("attrA='"));
1600 AngularPropertyElement element = node.element as AngularPropertyElement; 1560 AngularPropertyElement element = node.element as AngularPropertyElement;
1601 JUnitTestCase.assertNotNull(element); 1561 expect(element, isNotNull);
1602 JUnitTestCase.assertEquals("attrA", element.name); 1562 expect(element.name, "attrA");
1603 JUnitTestCase.assertEquals("setA", element.field.name); 1563 expect(element.field.name, "setA");
1604 } 1564 }
1605 // "attrB" attribute was resolved, even if it @binding 1565 // "attrB" attribute was resolved, even if it @binding
1606 { 1566 {
1607 ht.XmlAttributeNode node = 1567 ht.XmlAttributeNode node =
1608 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("attrB='")); 1568 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("attrB='"));
1609 AngularPropertyElement element = node.element as AngularPropertyElement; 1569 AngularPropertyElement element = node.element as AngularPropertyElement;
1610 JUnitTestCase.assertNotNull(element); 1570 expect(element, isNotNull);
1611 JUnitTestCase.assertEquals("attrB", element.name); 1571 expect(element.name, "attrB");
1612 JUnitTestCase.assertEquals("setB", element.field.name); 1572 expect(element.field.name, "setB");
1613 } 1573 }
1614 } 1574 }
1615 1575
1616 void test_NgDirective_noAttribute() { 1576 void test_NgDirective_noAttribute() {
1617 addMainSource(r''' 1577 addMainSource(r'''
1618 1578
1619 import 'angular.dart'; 1579 import 'angular.dart';
1620 1580
1621 @NgDirective(selector: '[my-directive]', map: const {'foo': '=>input'}) 1581 @NgDirective(selector: '[my-directive]', map: const {'foo': '=>input'})
1622 class MyDirective { 1582 class MyDirective {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 <input type='text' ng-model='name'> 1618 <input type='text' ng-model='name'>
1659 <div my-directive my-property='name != null'> 1619 <div my-directive my-property='name != null'>
1660 </div>''')); 1620 </div>'''));
1661 resolveMainNoErrors(); 1621 resolveMainNoErrors();
1662 // "my-directive" attribute was resolved 1622 // "my-directive" attribute was resolved
1663 { 1623 {
1664 AngularSelectorElement selector = 1624 AngularSelectorElement selector =
1665 findMainElement(ElementKind.ANGULAR_SELECTOR, "my-directive"); 1625 findMainElement(ElementKind.ANGULAR_SELECTOR, "my-directive");
1666 ht.XmlAttributeNode attrNodeSelector = 1626 ht.XmlAttributeNode attrNodeSelector =
1667 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("my-directive ")); 1627 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("my-directive "));
1668 JUnitTestCase.assertNotNull(attrNodeSelector); 1628 expect(attrNodeSelector, isNotNull);
1669 JUnitTestCase.assertSame(selector, attrNodeSelector.element); 1629 expect(attrNodeSelector.element, same(selector));
1670 } 1630 }
1671 // "my-property" attribute was resolved 1631 // "my-property" attribute was resolved
1672 { 1632 {
1673 ht.XmlAttributeNode attrNodeProperty = 1633 ht.XmlAttributeNode attrNodeProperty =
1674 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("my-property= '")); 1634 ht.HtmlUnitUtils.getAttributeNode(indexUnit, findOffset2("my-property= '"));
1675 AngularPropertyElement propertyElement = 1635 AngularPropertyElement propertyElement =
1676 attrNodeProperty.element as AngularPropertyElement; 1636 attrNodeProperty.element as AngularPropertyElement;
1677 JUnitTestCase.assertNotNull(propertyElement); 1637 expect(propertyElement, isNotNull);
1678 JUnitTestCase.assertSame( 1638 expect(propertyElement.propertyKind, same(AngularPropertyKind.ONE_WAY));
1679 AngularPropertyKind.ONE_WAY, 1639 expect(propertyElement.field.name, "condition");
1680 propertyElement.propertyKind);
1681 JUnitTestCase.assertEquals("condition", propertyElement.field.name);
1682 } 1640 }
1683 // "name" expression was resolved 1641 // "name" expression was resolved
1684 JUnitTestCase.assertNotNull(findIdentifier("name != null")); 1642 expect(findIdentifier("name != null"), isNotNull);
1685 } 1643 }
1686 1644
1687 void test_NgDirective_resolvedExpression_attrString() { 1645 void test_NgDirective_resolvedExpression_attrString() {
1688 addMainSource(r''' 1646 addMainSource(r'''
1689 1647
1690 import 'angular.dart'; 1648 import 'angular.dart';
1691 1649
1692 @NgDirective(selector: '[my-directive]) 1650 @NgDirective(selector: '[my-directive])
1693 class MyDirective { 1651 class MyDirective {
1694 @NgAttr('my-property') 1652 @NgAttr('my-property')
1695 String property; 1653 String property;
1696 }'''); 1654 }''');
1697 _resolveIndexNoErrors( 1655 _resolveIndexNoErrors(
1698 AngularTest.createHtmlWithMyController(r''' 1656 AngularTest.createHtmlWithMyController(r'''
1699 <input type='text' ng-model='name'> 1657 <input type='text' ng-model='name'>
1700 <div my-directive my-property='name != null'> 1658 <div my-directive my-property='name != null'>
1701 </div>''')); 1659 </div>'''));
1702 resolveMain(); 1660 resolveMain();
1703 // @NgAttr means "string attribute", which we don't parse 1661 // @NgAttr means "string attribute", which we don't parse
1704 JUnitTestCase.assertNull(findIdentifierMaybe("name != null")); 1662 expect(findIdentifierMaybe("name != null"), isNull);
1705 } 1663 }
1706 1664
1707 void test_NgDirective_resolvedExpression_dotAsName() { 1665 void test_NgDirective_resolvedExpression_dotAsName() {
1708 addMainSource(r''' 1666 addMainSource(r'''
1709 1667
1710 import 'angular.dart'; 1668 import 'angular.dart';
1711 1669
1712 @Decorator( 1670 @Decorator(
1713 selector: '[my-directive]', 1671 selector: '[my-directive]',
1714 map: const {'.' : '=>condition'}) 1672 map: const {'.' : '=>condition'})
1715 class MyDirective { 1673 class MyDirective {
1716 set condition(value) {} 1674 set condition(value) {}
1717 }'''); 1675 }''');
1718 _resolveIndexNoErrors( 1676 _resolveIndexNoErrors(
1719 AngularTest.createHtmlWithMyController(r''' 1677 AngularTest.createHtmlWithMyController(r'''
1720 <input type='text' ng-model='name'> 1678 <input type='text' ng-model='name'>
1721 <div my-directive='name != null'> 1679 <div my-directive='name != null'>
1722 </div>''')); 1680 </div>'''));
1723 // "name" attribute was resolved 1681 // "name" attribute was resolved
1724 JUnitTestCase.assertNotNull(findIdentifier("name != null")); 1682 expect(findIdentifier("name != null"), isNotNull);
1725 } 1683 }
1726 1684
1727 void fail_analysisContext_changeDart_invalidateApplication() { 1685 void fail_analysisContext_changeDart_invalidateApplication() {
1728 addMainSource(r''' 1686 addMainSource(r'''
1729 1687
1730 import 'angular.dart'; 1688 import 'angular.dart';
1731 1689
1732 @Component( 1690 @Component(
1733 templateUrl: 'my_template.html', cssUrl: 'my_styles.css', 1691 templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
1734 publishAs: 'ctrl', 1692 publishAs: 'ctrl',
1735 selector: 'myComponent') 1693 selector: 'myComponent')
1736 class MyComponent { 1694 class MyComponent {
1737 }'''); 1695 }''');
1738 contextHelper.addSource( 1696 contextHelper.addSource(
1739 "/entry-point.html", 1697 "/entry-point.html",
1740 AngularTest.createHtmlWithAngular('')); 1698 AngularTest.createHtmlWithAngular(''));
1741 addIndexSource2( 1699 addIndexSource2(
1742 "/my_template.html", 1700 "/my_template.html",
1743 r''' 1701 r'''
1744 <div> 1702 <div>
1745 {{ctrl.noMethod()}} 1703 {{ctrl.noMethod()}}
1746 </div>'''); 1704 </div>''');
1747 contextHelper.addSource("/my_styles.css", ""); 1705 contextHelper.addSource("/my_styles.css", "");
1748 contextHelper.runTasks(); 1706 contextHelper.runTasks();
1749 // there are some errors in my_template.html 1707 // there are some errors in my_template.html
1750 { 1708 {
1751 List<AnalysisError> errors = context.getErrors(indexSource).errors; 1709 List<AnalysisError> errors = context.getErrors(indexSource).errors;
1752 JUnitTestCase.assertTrue(errors.length != 0); 1710 expect(errors.length != 0, isTrue);
1753 } 1711 }
1754 // change main.dart, there are no MyComponent anymore 1712 // change main.dart, there are no MyComponent anymore
1755 context.setContents(mainSource, ""); 1713 context.setContents(mainSource, "");
1756 // ...errors in my_template.html should be removed 1714 // ...errors in my_template.html should be removed
1757 { 1715 {
1758 List<AnalysisError> errors = context.getErrors(indexSource).errors; 1716 List<AnalysisError> errors = context.getErrors(indexSource).errors;
1759 _ut.expect(errors, _ut.isEmpty); 1717 expect(errors, isEmpty);
1760 JUnitTestCase.assertTrue(errors.length == 0); 1718 expect(errors.length == 0, isTrue);
1761 } 1719 }
1762 } 1720 }
1763 1721
1764 void test_analysisContext_changeEntryPoint_clearAngularErrors_inDart() { 1722 void test_analysisContext_changeEntryPoint_clearAngularErrors_inDart() {
1765 addMainSource(r''' 1723 addMainSource(r'''
1766 1724
1767 import 'angular.dart'; 1725 import 'angular.dart';
1768 1726
1769 @Component( 1727 @Component(
1770 templateUrl: 'no-such-template.html', cssUrl: 'my_styles.css', 1728 templateUrl: 'no-such-template.html', cssUrl: 'my_styles.css',
1771 publishAs: 'ctrl', 1729 publishAs: 'ctrl',
1772 selector: 'myComponent') 1730 selector: 'myComponent')
1773 class MyComponent { 1731 class MyComponent {
1774 }'''); 1732 }''');
1775 Source entrySource = contextHelper.addSource( 1733 Source entrySource = contextHelper.addSource(
1776 "/entry-point.html", 1734 "/entry-point.html",
1777 AngularTest.createHtmlWithAngular('')); 1735 AngularTest.createHtmlWithAngular(''));
1778 contextHelper.addSource("/my_styles.css", ""); 1736 contextHelper.addSource("/my_styles.css", "");
1779 contextHelper.runTasks(); 1737 contextHelper.runTasks();
1780 // there are some errors in MyComponent 1738 // there are some errors in MyComponent
1781 { 1739 {
1782 List<AnalysisError> errors = context.getErrors(mainSource).errors; 1740 List<AnalysisError> errors = context.getErrors(mainSource).errors;
1783 JUnitTestCase.assertTrue(errors.length != 0); 1741 expect(errors.length != 0, isTrue);
1784 } 1742 }
1785 // make entry-point.html non-Angular 1743 // make entry-point.html non-Angular
1786 context.setContents(entrySource, "<html/>"); 1744 context.setContents(entrySource, "<html/>");
1787 // ...errors in MyComponent should be removed 1745 // ...errors in MyComponent should be removed
1788 { 1746 {
1789 List<AnalysisError> errors = context.getErrors(mainSource).errors; 1747 List<AnalysisError> errors = context.getErrors(mainSource).errors;
1790 JUnitTestCase.assertTrue(errors.length == 0); 1748 expect(errors.length == 0, isTrue);
1791 } 1749 }
1792 } 1750 }
1793 1751
1794 void test_analysisContext_changeEntryPoint_clearAngularErrors_inTemplate() { 1752 void test_analysisContext_changeEntryPoint_clearAngularErrors_inTemplate() {
1795 addMainSource(r''' 1753 addMainSource(r'''
1796 1754
1797 import 'angular.dart'; 1755 import 'angular.dart';
1798 1756
1799 @Component( 1757 @Component(
1800 templateUrl: 'my_template.html', cssUrl: 'my_styles.css', 1758 templateUrl: 'my_template.html', cssUrl: 'my_styles.css',
1801 publishAs: 'ctrl', 1759 publishAs: 'ctrl',
1802 selector: 'myComponent') 1760 selector: 'myComponent')
1803 class MyComponent { 1761 class MyComponent {
1804 }'''); 1762 }''');
1805 Source entrySource = contextHelper.addSource( 1763 Source entrySource = contextHelper.addSource(
1806 "/entry-point.html", 1764 "/entry-point.html",
1807 AngularTest.createHtmlWithAngular('')); 1765 AngularTest.createHtmlWithAngular(''));
1808 addIndexSource2( 1766 addIndexSource2(
1809 "/my_template.html", 1767 "/my_template.html",
1810 r''' 1768 r'''
1811 <div> 1769 <div>
1812 {{ctrl.noMethod()}} 1770 {{ctrl.noMethod()}}
1813 </div>'''); 1771 </div>''');
1814 contextHelper.addSource("/my_styles.css", ""); 1772 contextHelper.addSource("/my_styles.css", "");
1815 contextHelper.runTasks(); 1773 contextHelper.runTasks();
1816 // there are some errors in my_template.html 1774 // there are some errors in my_template.html
1817 { 1775 {
1818 List<AnalysisError> errors = context.getErrors(indexSource).errors; 1776 List<AnalysisError> errors = context.getErrors(indexSource).errors;
1819 JUnitTestCase.assertTrue(errors.length != 0); 1777 expect(errors.length != 0, isTrue);
1820 } 1778 }
1821 // make entry-point.html non-Angular 1779 // make entry-point.html non-Angular
1822 context.setContents(entrySource, "<html/>"); 1780 context.setContents(entrySource, "<html/>");
1823 // ...errors in my_template.html should be removed 1781 // ...errors in my_template.html should be removed
1824 { 1782 {
1825 List<AnalysisError> errors = context.getErrors(indexSource).errors; 1783 List<AnalysisError> errors = context.getErrors(indexSource).errors;
1826 JUnitTestCase.assertTrue(errors.length == 0); 1784 expect(errors.length == 0, isTrue);
1827 } 1785 }
1828 } 1786 }
1829 1787
1830 void test_analysisContext_removeEntryPoint_clearAngularErrors_inDart() { 1788 void test_analysisContext_removeEntryPoint_clearAngularErrors_inDart() {
1831 addMainSource(r''' 1789 addMainSource(r'''
1832 1790
1833 import 'angular.dart'; 1791 import 'angular.dart';
1834 1792
1835 @Component( 1793 @Component(
1836 templateUrl: 'no-such-template.html', cssUrl: 'my_styles.css', 1794 templateUrl: 'no-such-template.html', cssUrl: 'my_styles.css',
1837 publishAs: 'ctrl', 1795 publishAs: 'ctrl',
1838 selector: 'myComponent') 1796 selector: 'myComponent')
1839 class MyComponent { 1797 class MyComponent {
1840 }'''); 1798 }''');
1841 Source entrySource = contextHelper.addSource( 1799 Source entrySource = contextHelper.addSource(
1842 "/entry-point.html", 1800 "/entry-point.html",
1843 AngularTest.createHtmlWithAngular('')); 1801 AngularTest.createHtmlWithAngular(''));
1844 contextHelper.addSource("/my_styles.css", ""); 1802 contextHelper.addSource("/my_styles.css", "");
1845 contextHelper.runTasks(); 1803 contextHelper.runTasks();
1846 // there are some errors in MyComponent 1804 // there are some errors in MyComponent
1847 { 1805 {
1848 List<AnalysisError> errors = context.getErrors(mainSource).errors; 1806 List<AnalysisError> errors = context.getErrors(mainSource).errors;
1849 JUnitTestCase.assertTrue(errors.length != 0); 1807 expect(errors.length != 0, isTrue);
1850 } 1808 }
1851 // remove entry-point.html 1809 // remove entry-point.html
1852 { 1810 {
1853 ChangeSet changeSet = new ChangeSet(); 1811 ChangeSet changeSet = new ChangeSet();
1854 changeSet.removedSource(entrySource); 1812 changeSet.removedSource(entrySource);
1855 context.applyChanges(changeSet); 1813 context.applyChanges(changeSet);
1856 } 1814 }
1857 // ...errors in MyComponent should be removed 1815 // ...errors in MyComponent should be removed
1858 { 1816 {
1859 List<AnalysisError> errors = context.getErrors(mainSource).errors; 1817 List<AnalysisError> errors = context.getErrors(mainSource).errors;
1860 JUnitTestCase.assertTrue(errors.length == 0); 1818 expect(errors.length == 0, isTrue);
1861 } 1819 }
1862 } 1820 }
1863 1821
1864 void test_contextProperties() { 1822 void test_contextProperties() {
1865 addMyController(); 1823 addMyController();
1866 _resolveIndexNoErrors( 1824 _resolveIndexNoErrors(
1867 AngularTest.createHtmlWithAngular(r''' 1825 AngularTest.createHtmlWithAngular(r'''
1868 <div> 1826 <div>
1869 {{$id}} 1827 {{$id}}
1870 {{$parent}} 1828 {{$parent}}
1871 {{$root}} 1829 {{$root}}
1872 </div>''')); 1830 </div>'''));
1873 assertResolvedIdentifier("\$id"); 1831 assertResolvedIdentifier("\$id");
1874 assertResolvedIdentifier("\$parent"); 1832 assertResolvedIdentifier("\$parent");
1875 assertResolvedIdentifier("\$root"); 1833 assertResolvedIdentifier("\$root");
1876 } 1834 }
1877 1835
1878 void test_getAngularElement_isAngular() { 1836 void test_getAngularElement_isAngular() {
1879 // prepare local variable "name" in compilation unit 1837 // prepare local variable "name" in compilation unit
1880 CompilationUnitElementImpl unit = 1838 CompilationUnitElementImpl unit =
1881 ElementFactory.compilationUnit("test.dart"); 1839 ElementFactory.compilationUnit("test.dart");
1882 FunctionElementImpl function = ElementFactory.functionElement("main"); 1840 FunctionElementImpl function = ElementFactory.functionElement("main");
1883 unit.functions = <FunctionElement>[function]; 1841 unit.functions = <FunctionElement>[function];
1884 LocalVariableElementImpl local = 1842 LocalVariableElementImpl local =
1885 ElementFactory.localVariableElement2("name"); 1843 ElementFactory.localVariableElement2("name");
1886 function.localVariables = <LocalVariableElement>[local]; 1844 function.localVariables = <LocalVariableElement>[local];
1887 // set AngularElement 1845 // set AngularElement
1888 AngularElement angularElement = new AngularControllerElementImpl("ctrl", 0); 1846 AngularElement angularElement = new AngularControllerElementImpl("ctrl", 0);
1889 local.toolkitObjects = <AngularElement>[angularElement]; 1847 local.toolkitObjects = <AngularElement>[angularElement];
1890 JUnitTestCase.assertSame( 1848 expect(AngularHtmlUnitResolver.getAngularElement(local), same(angularElement ));
1891 angularElement,
1892 AngularHtmlUnitResolver.getAngularElement(local));
1893 } 1849 }
1894 1850
1895 void test_getAngularElement_notAngular() { 1851 void test_getAngularElement_notAngular() {
1896 Element element = ElementFactory.localVariableElement2("name"); 1852 Element element = ElementFactory.localVariableElement2("name");
1897 JUnitTestCase.assertNull( 1853 expect(AngularHtmlUnitResolver.getAngularElement(element), isNull);
1898 AngularHtmlUnitResolver.getAngularElement(element));
1899 } 1854 }
1900 1855
1901 void test_getAngularElement_notLocal() { 1856 void test_getAngularElement_notLocal() {
1902 Element element = ElementFactory.classElement2("Test", []); 1857 Element element = ElementFactory.classElement2("Test", []);
1903 JUnitTestCase.assertNull( 1858 expect(AngularHtmlUnitResolver.getAngularElement(element), isNull);
1904 AngularHtmlUnitResolver.getAngularElement(element));
1905 } 1859 }
1906 1860
1907 /** 1861 /**
1908 * Test that we resolve "ng-click" expression. 1862 * Test that we resolve "ng-click" expression.
1909 */ 1863 */
1910 void test_ngClick() { 1864 void test_ngClick() {
1911 addMyController(); 1865 addMyController();
1912 _resolveIndexNoErrors( 1866 _resolveIndexNoErrors(
1913 AngularTest.createHtmlWithMyController(r"<button ng-click='ctrl.doSometh ing($event)'/>")); 1867 AngularTest.createHtmlWithMyController(r"<button ng-click='ctrl.doSometh ing($event)'/>"));
1914 assertResolvedIdentifier("doSomething"); 1868 assertResolvedIdentifier("doSomething");
(...skipping 20 matching lines...) Expand all
1935 } 1889 }
1936 1890
1937 void test_ngModel_modelBeforeUsage() { 1891 void test_ngModel_modelBeforeUsage() {
1938 addMyController(); 1892 addMyController();
1939 _resolveIndexNoErrors( 1893 _resolveIndexNoErrors(
1940 AngularTest.createHtmlWithMyController(r''' 1894 AngularTest.createHtmlWithMyController(r'''
1941 <input type='text' ng-model='name'> 1895 <input type='text' ng-model='name'>
1942 <h3>Hello {{name}}!</h3>''')); 1896 <h3>Hello {{name}}!</h3>'''));
1943 assertResolvedIdentifier2("name}}!", "String"); 1897 assertResolvedIdentifier2("name}}!", "String");
1944 Element element = assertResolvedIdentifier2("name'>", "String"); 1898 Element element = assertResolvedIdentifier2("name'>", "String");
1945 JUnitTestCase.assertEquals("name", element.name); 1899 expect(element.name, "name");
1946 JUnitTestCase.assertEquals(findOffset2("name'>"), element.nameOffset); 1900 expect(element.nameOffset, findOffset2("name'>"));
1947 } 1901 }
1948 1902
1949 void test_ngModel_notIdentifier() { 1903 void test_ngModel_notIdentifier() {
1950 addMyController(); 1904 addMyController();
1951 _resolveIndexNoErrors( 1905 _resolveIndexNoErrors(
1952 AngularTest.createHtmlWithMyController("<input type='text' ng-model='ctr l.field'>")); 1906 AngularTest.createHtmlWithMyController("<input type='text' ng-model='ctr l.field'>"));
1953 assertResolvedIdentifier2("field'>", "String"); 1907 assertResolvedIdentifier2("field'>", "String");
1954 } 1908 }
1955 1909
1956 /** 1910 /**
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 <body> 2111 <body>
2158 <div my-marker> 2112 <div my-marker>
2159 {{ctrl.field}} 2113 {{ctrl.field}}
2160 </div> 2114 </div>
2161 </body> 2115 </body>
2162 </html>'''); 2116 </html>''');
2163 assertNoErrors(); 2117 assertNoErrors();
2164 // Angular is not initialized, so "ctrl" is not parsed 2118 // Angular is not initialized, so "ctrl" is not parsed
2165 Expression expression = 2119 Expression expression =
2166 ht.HtmlUnitUtils.getExpression(indexUnit, findOffset2("ctrl")); 2120 ht.HtmlUnitUtils.getExpression(indexUnit, findOffset2("ctrl"));
2167 JUnitTestCase.assertNull(expression); 2121 expect(expression, isNull);
2168 } 2122 }
2169 2123
2170 void test_notResolved_notAngular() { 2124 void test_notResolved_notAngular() {
2171 resolveIndex2(r''' 2125 resolveIndex2(r'''
2172 <html no-ng-app> 2126 <html no-ng-app>
2173 <body> 2127 <body>
2174 <div my-marker> 2128 <div my-marker>
2175 {{ctrl.field}} 2129 {{ctrl.field}}
2176 </div> 2130 </div>
2177 </body> 2131 </body>
2178 </html>'''); 2132 </html>''');
2179 assertNoErrors(); 2133 assertNoErrors();
2180 // Angular is not initialized, so "ctrl" is not parsed 2134 // Angular is not initialized, so "ctrl" is not parsed
2181 Expression expression = 2135 Expression expression =
2182 ht.HtmlUnitUtils.getExpression(indexUnit, findOffset2("ctrl")); 2136 ht.HtmlUnitUtils.getExpression(indexUnit, findOffset2("ctrl"));
2183 JUnitTestCase.assertNull(expression); 2137 expect(expression, isNull);
2184 } 2138 }
2185 2139
2186 void test_notResolved_wrongControllerMarker() { 2140 void test_notResolved_wrongControllerMarker() {
2187 addMyController(); 2141 addMyController();
2188 addIndexSource(r''' 2142 addIndexSource(r'''
2189 <html ng-app> 2143 <html ng-app>
2190 <body> 2144 <body>
2191 <div not-my-marker> 2145 <div not-my-marker>
2192 {{ctrl.field}} 2146 {{ctrl.field}}
2193 </div> 2147 </div>
2194 <script type='application/dart' src='main.dart'></script> 2148 <script type='application/dart' src='main.dart'></script>
2195 </body> 2149 </body>
2196 </html>'''); 2150 </html>''');
2197 contextHelper.runTasks(); 2151 contextHelper.runTasks();
2198 resolveIndex(); 2152 resolveIndex();
2199 // no errors, because we decided to ignore them at the moment 2153 // no errors, because we decided to ignore them at the moment
2200 assertNoErrors(); 2154 assertNoErrors();
2201 // "ctrl" is not resolved 2155 // "ctrl" is not resolved
2202 SimpleIdentifier identifier = findIdentifier("ctrl"); 2156 SimpleIdentifier identifier = findIdentifier("ctrl");
2203 JUnitTestCase.assertNull(identifier.bestElement); 2157 expect(identifier.bestElement, isNull);
2204 } 2158 }
2205 2159
2206 void test_resolveExpression_evenWithout_ngBootstrap() { 2160 void test_resolveExpression_evenWithout_ngBootstrap() {
2207 resolveMainSource(r''' 2161 resolveMainSource(r'''
2208 2162
2209 import 'angular.dart'; 2163 import 'angular.dart';
2210 2164
2211 @Controller( 2165 @Controller(
2212 selector: '[my-controller]', 2166 selector: '[my-controller]',
2213 publishAs: 'ctrl') 2167 publishAs: 'ctrl')
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 <script type='application/dart' src='main.dart'></script> 2203 <script type='application/dart' src='main.dart'></script>
2250 </body> 2204 </body>
2251 </html>'''); 2205 </html>''');
2252 assertNoErrors(); 2206 assertNoErrors();
2253 // "ctrl.map" and "ctrl.obj" are resolved 2207 // "ctrl.map" and "ctrl.obj" are resolved
2254 assertResolvedIdentifier2("map", "Map<dynamic, dynamic>"); 2208 assertResolvedIdentifier2("map", "Map<dynamic, dynamic>");
2255 assertResolvedIdentifier2("obj", "Object"); 2209 assertResolvedIdentifier2("obj", "Object");
2256 // ...but not "invisibleScopeProperty" 2210 // ...but not "invisibleScopeProperty"
2257 { 2211 {
2258 SimpleIdentifier identifier = findIdentifier("invisibleScopeProperty"); 2212 SimpleIdentifier identifier = findIdentifier("invisibleScopeProperty");
2259 JUnitTestCase.assertNull(identifier.bestElement); 2213 expect(identifier.bestElement, isNull);
2260 } 2214 }
2261 } 2215 }
2262 2216
2263 void test_resolveExpression_inAttribute() { 2217 void test_resolveExpression_inAttribute() {
2264 addMyController(); 2218 addMyController();
2265 _resolveIndexNoErrors( 2219 _resolveIndexNoErrors(
2266 AngularTest.createHtmlWithMyController("<button title='{{ctrl.field}}'>< /button>")); 2220 AngularTest.createHtmlWithMyController("<button title='{{ctrl.field}}'>< /button>"));
2267 assertResolvedIdentifier2("ctrl", "MyController"); 2221 assertResolvedIdentifier2("ctrl", "MyController");
2268 } 2222 }
2269 2223
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 _resolveSimpleCtrlFieldHtml(); 2381 _resolveSimpleCtrlFieldHtml();
2428 // prepare expression 2382 // prepare expression
2429 int offset = indexContent.indexOf("ctrl"); 2383 int offset = indexContent.indexOf("ctrl");
2430 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset); 2384 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
2431 // get element 2385 // get element
2432 Element element = ht.HtmlUnitUtils.getElementToOpen(indexUnit, expression); 2386 Element element = ht.HtmlUnitUtils.getElementToOpen(indexUnit, expression);
2433 EngineTestCase.assertInstanceOf( 2387 EngineTestCase.assertInstanceOf(
2434 (obj) => obj is AngularControllerElement, 2388 (obj) => obj is AngularControllerElement,
2435 AngularControllerElement, 2389 AngularControllerElement,
2436 element); 2390 element);
2437 JUnitTestCase.assertEquals("ctrl", element.name); 2391 expect(element.name, "ctrl");
2438 } 2392 }
2439 2393
2440 void test_getElementToOpen_field() { 2394 void test_getElementToOpen_field() {
2441 addMyController(); 2395 addMyController();
2442 _resolveSimpleCtrlFieldHtml(); 2396 _resolveSimpleCtrlFieldHtml();
2443 // prepare expression 2397 // prepare expression
2444 int offset = indexContent.indexOf("field"); 2398 int offset = indexContent.indexOf("field");
2445 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset); 2399 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
2446 // get element 2400 // get element
2447 Element element = ht.HtmlUnitUtils.getElementToOpen(indexUnit, expression); 2401 Element element = ht.HtmlUnitUtils.getElementToOpen(indexUnit, expression);
2448 EngineTestCase.assertInstanceOf( 2402 EngineTestCase.assertInstanceOf(
2449 (obj) => obj is PropertyAccessorElement, 2403 (obj) => obj is PropertyAccessorElement,
2450 PropertyAccessorElement, 2404 PropertyAccessorElement,
2451 element); 2405 element);
2452 JUnitTestCase.assertEquals("field", element.name); 2406 expect(element.name, "field");
2453 } 2407 }
2454 2408
2455 void test_getElement_forExpression() { 2409 void test_getElement_forExpression() {
2456 addMyController(); 2410 addMyController();
2457 _resolveSimpleCtrlFieldHtml(); 2411 _resolveSimpleCtrlFieldHtml();
2458 // prepare expression 2412 // prepare expression
2459 int offset = indexContent.indexOf("ctrl"); 2413 int offset = indexContent.indexOf("ctrl");
2460 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset); 2414 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
2461 // get element 2415 // get element
2462 Element element = ht.HtmlUnitUtils.getElement(expression); 2416 Element element = ht.HtmlUnitUtils.getElement(expression);
2463 EngineTestCase.assertInstanceOf( 2417 EngineTestCase.assertInstanceOf(
2464 (obj) => obj is VariableElement, 2418 (obj) => obj is VariableElement,
2465 VariableElement, 2419 VariableElement,
2466 element); 2420 element);
2467 JUnitTestCase.assertEquals("ctrl", element.name); 2421 expect(element.name, "ctrl");
2468 } 2422 }
2469 2423
2470 void test_getElement_forExpression_null() { 2424 void test_getElement_forExpression_null() {
2471 Element element = ht.HtmlUnitUtils.getElement(null); 2425 Element element = ht.HtmlUnitUtils.getElement(null);
2472 JUnitTestCase.assertNull(element); 2426 expect(element, isNull);
2473 } 2427 }
2474 2428
2475 void test_getElement_forOffset() { 2429 void test_getElement_forOffset() {
2476 addMyController(); 2430 addMyController();
2477 _resolveSimpleCtrlFieldHtml(); 2431 _resolveSimpleCtrlFieldHtml();
2478 // no expression 2432 // no expression
2479 { 2433 {
2480 Element element = ht.HtmlUnitUtils.getElementAtOffset(indexUnit, 0); 2434 Element element = ht.HtmlUnitUtils.getElementAtOffset(indexUnit, 0);
2481 JUnitTestCase.assertNull(element); 2435 expect(element, isNull);
2482 } 2436 }
2483 // has expression at offset 2437 // has expression at offset
2484 { 2438 {
2485 int offset = indexContent.indexOf("field"); 2439 int offset = indexContent.indexOf("field");
2486 Element element = ht.HtmlUnitUtils.getElementAtOffset(indexUnit, offset); 2440 Element element = ht.HtmlUnitUtils.getElementAtOffset(indexUnit, offset);
2487 EngineTestCase.assertInstanceOf( 2441 EngineTestCase.assertInstanceOf(
2488 (obj) => obj is PropertyAccessorElement, 2442 (obj) => obj is PropertyAccessorElement,
2489 PropertyAccessorElement, 2443 PropertyAccessorElement,
2490 element); 2444 element);
2491 JUnitTestCase.assertEquals("field", element.name); 2445 expect(element.name, "field");
2492 } 2446 }
2493 } 2447 }
2494 2448
2495 void test_getEnclosingTagNode() { 2449 void test_getEnclosingTagNode() {
2496 resolveIndex2(r''' 2450 resolveIndex2(r'''
2497 <html> 2451 <html>
2498 <body ng-app> 2452 <body ng-app>
2499 <badge name='abc'> 123 </badge> 2453 <badge name='abc'> 123 </badge>
2500 </body> 2454 </body>
2501 </html>'''); 2455 </html>''');
2502 // no unit 2456 // no unit
2503 JUnitTestCase.assertNull(ht.HtmlUnitUtils.getEnclosingTagNode(null, 0)); 2457 expect(ht.HtmlUnitUtils.getEnclosingTagNode(null, 0), isNull);
2504 // wrong offset 2458 // wrong offset
2505 JUnitTestCase.assertNull( 2459 expect(ht.HtmlUnitUtils.getEnclosingTagNode(indexUnit, -1), isNull);
2506 ht.HtmlUnitUtils.getEnclosingTagNode(indexUnit, -1));
2507 // valid offset 2460 // valid offset
2508 ht.XmlTagNode expected = _getEnclosingTagNode("<badge"); 2461 ht.XmlTagNode expected = _getEnclosingTagNode("<badge");
2509 JUnitTestCase.assertNotNull(expected); 2462 expect(expected, isNotNull);
2510 JUnitTestCase.assertEquals("badge", expected.tag); 2463 expect(expected.tag, "badge");
2511 JUnitTestCase.assertSame(expected, _getEnclosingTagNode("badge")); 2464 expect(_getEnclosingTagNode("badge"), same(expected));
2512 JUnitTestCase.assertSame(expected, _getEnclosingTagNode("name=")); 2465 expect(_getEnclosingTagNode("name="), same(expected));
2513 JUnitTestCase.assertSame(expected, _getEnclosingTagNode("123")); 2466 expect(_getEnclosingTagNode("123"), same(expected));
2514 JUnitTestCase.assertSame(expected, _getEnclosingTagNode("/badge")); 2467 expect(_getEnclosingTagNode("/badge"), same(expected));
2515 } 2468 }
2516 2469
2517 void test_getExpression() { 2470 void test_getExpression() {
2518 addMyController(); 2471 addMyController();
2519 _resolveSimpleCtrlFieldHtml(); 2472 _resolveSimpleCtrlFieldHtml();
2520 // try offset without expression 2473 // try offset without expression
2521 JUnitTestCase.assertNull(ht.HtmlUnitUtils.getExpression(indexUnit, 0)); 2474 expect(ht.HtmlUnitUtils.getExpression(indexUnit, 0), isNull);
2522 // try offset with expression 2475 // try offset with expression
2523 int offset = indexContent.indexOf("ctrl"); 2476 int offset = indexContent.indexOf("ctrl");
2524 JUnitTestCase.assertNotNull( 2477 expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset), isNotNull);
2525 ht.HtmlUnitUtils.getExpression(indexUnit, offset)); 2478 expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset + 1), isNotNull);
2526 JUnitTestCase.assertNotNull( 2479 expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset + 2), isNotNull);
2527 ht.HtmlUnitUtils.getExpression(indexUnit, offset + 1)); 2480 expect(ht.HtmlUnitUtils.getExpression(indexUnit, offset + "ctrl.field".lengt h), isNotNull);
2528 JUnitTestCase.assertNotNull(
2529 ht.HtmlUnitUtils.getExpression(indexUnit, offset + 2));
2530 JUnitTestCase.assertNotNull(
2531 ht.HtmlUnitUtils.getExpression(indexUnit, offset + "ctrl.field".length)) ;
2532 // try without unit 2481 // try without unit
2533 JUnitTestCase.assertNull(ht.HtmlUnitUtils.getExpression(null, offset)); 2482 expect(ht.HtmlUnitUtils.getExpression(null, offset), isNull);
2534 } 2483 }
2535 2484
2536 void test_getTagNode() { 2485 void test_getTagNode() {
2537 resolveIndex2(r''' 2486 resolveIndex2(r'''
2538 <html> 2487 <html>
2539 <body ng-app> 2488 <body ng-app>
2540 <badge name='abc'> 123 </badge> done 2489 <badge name='abc'> 123 </badge> done
2541 </body> 2490 </body>
2542 </html>'''); 2491 </html>''');
2543 // no unit 2492 // no unit
2544 JUnitTestCase.assertNull(ht.HtmlUnitUtils.getTagNode(null, 0)); 2493 expect(ht.HtmlUnitUtils.getTagNode(null, 0), isNull);
2545 // wrong offset 2494 // wrong offset
2546 JUnitTestCase.assertNull(ht.HtmlUnitUtils.getTagNode(indexUnit, -1)); 2495 expect(ht.HtmlUnitUtils.getTagNode(indexUnit, -1), isNull);
2547 // on tag name 2496 // on tag name
2548 ht.XmlTagNode expected = _getTagNode("badge name="); 2497 ht.XmlTagNode expected = _getTagNode("badge name=");
2549 JUnitTestCase.assertNotNull(expected); 2498 expect(expected, isNotNull);
2550 JUnitTestCase.assertEquals("badge", expected.tag); 2499 expect(expected.tag, "badge");
2551 JUnitTestCase.assertSame(expected, _getTagNode("badge")); 2500 expect(_getTagNode("badge"), same(expected));
2552 JUnitTestCase.assertSame(expected, _getTagNode(" name=")); 2501 expect(_getTagNode(" name="), same(expected));
2553 JUnitTestCase.assertSame(expected, _getTagNode("adge name=")); 2502 expect(_getTagNode("adge name="), same(expected));
2554 JUnitTestCase.assertSame(expected, _getTagNode("badge>")); 2503 expect(_getTagNode("badge>"), same(expected));
2555 JUnitTestCase.assertSame(expected, _getTagNode("adge>")); 2504 expect(_getTagNode("adge>"), same(expected));
2556 JUnitTestCase.assertSame(expected, _getTagNode("> done")); 2505 expect(_getTagNode("> done"), same(expected));
2557 // in tag node, but not on the name token 2506 // in tag node, but not on the name token
2558 JUnitTestCase.assertNull(_getTagNode("name=")); 2507 expect(_getTagNode("name="), isNull);
2559 JUnitTestCase.assertNull(_getTagNode("123")); 2508 expect(_getTagNode("123"), isNull);
2560 } 2509 }
2561 2510
2562 ht.XmlTagNode _getEnclosingTagNode(String search) { 2511 ht.XmlTagNode _getEnclosingTagNode(String search) {
2563 return ht.HtmlUnitUtils.getEnclosingTagNode( 2512 return ht.HtmlUnitUtils.getEnclosingTagNode(
2564 indexUnit, 2513 indexUnit,
2565 indexContent.indexOf(search)); 2514 indexContent.indexOf(search));
2566 } 2515 }
2567 2516
2568 ht.XmlTagNode _getTagNode(String search) { 2517 ht.XmlTagNode _getTagNode(String search) {
2569 return ht.HtmlUnitUtils.getTagNode(indexUnit, indexContent.indexOf(search)); 2518 return ht.HtmlUnitUtils.getTagNode(indexUnit, indexContent.indexOf(search));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 } 2633 }
2685 2634
2686 /** 2635 /**
2687 * Checks that [indexHtmlUnit] has [SimpleIdentifier] with given name, resolve d to 2636 * Checks that [indexHtmlUnit] has [SimpleIdentifier] with given name, resolve d to
2688 * not `null` [Element]. 2637 * not `null` [Element].
2689 */ 2638 */
2690 Element assertResolvedIdentifier(String name) { 2639 Element assertResolvedIdentifier(String name) {
2691 SimpleIdentifier identifier = findIdentifier(name); 2640 SimpleIdentifier identifier = findIdentifier(name);
2692 // check Element 2641 // check Element
2693 Element element = identifier.bestElement; 2642 Element element = identifier.bestElement;
2694 JUnitTestCase.assertNotNull(element); 2643 expect(element, isNotNull);
2695 // return Element for further analysis 2644 // return Element for further analysis
2696 return element; 2645 return element;
2697 } 2646 }
2698 2647
2699 Element assertResolvedIdentifier2(String name, String expectedTypeName) { 2648 Element assertResolvedIdentifier2(String name, String expectedTypeName) {
2700 SimpleIdentifier identifier = findIdentifier(name); 2649 SimpleIdentifier identifier = findIdentifier(name);
2701 // check Element 2650 // check Element
2702 Element element = identifier.bestElement; 2651 Element element = identifier.bestElement;
2703 JUnitTestCase.assertNotNull(element); 2652 expect(element, isNotNull);
2704 // check Type 2653 // check Type
2705 DartType type = identifier.bestType; 2654 DartType type = identifier.bestType;
2706 JUnitTestCase.assertNotNull(type); 2655 expect(type, isNotNull);
2707 JUnitTestCase.assertEquals(expectedTypeName, type.toString()); 2656 expect(type.toString(), expectedTypeName);
2708 // return Element for further analysis 2657 // return Element for further analysis
2709 return element; 2658 return element;
2710 } 2659 }
2711 2660
2712 /** 2661 /**
2713 * @return [AstNode] which has required offset and type. 2662 * @return [AstNode] which has required offset and type.
2714 */ 2663 */
2715 AstNode findExpression(int offset, Predicate<AstNode> predicate) { 2664 AstNode findExpression(int offset, Predicate<AstNode> predicate) {
2716 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset); 2665 Expression expression = ht.HtmlUnitUtils.getExpression(indexUnit, offset);
2717 return expression != null ? expression.getAncestor(predicate) : null; 2666 return expression != null ? expression.getAncestor(predicate) : null;
2718 } 2667 }
2719 2668
2720 /** 2669 /**
2721 * Returns the [SimpleIdentifier] at the given search pattern. Fails if not fo und. 2670 * Returns the [SimpleIdentifier] at the given search pattern. Fails if not fo und.
2722 */ 2671 */
2723 SimpleIdentifier findIdentifier(String search) { 2672 SimpleIdentifier findIdentifier(String search) {
2724 SimpleIdentifier identifier = findIdentifierMaybe(search); 2673 SimpleIdentifier identifier = findIdentifierMaybe(search);
2725 JUnitTestCase.assertNotNullMsg("$search in $indexContent", identifier); 2674 expect(identifier, isNotNull, reason: "$search in $indexContent");
2726 // check that offset/length of the identifier is valid 2675 // check that offset/length of the identifier is valid
2727 { 2676 {
2728 int offset = identifier.offset; 2677 int offset = identifier.offset;
2729 int end = identifier.end; 2678 int end = identifier.end;
2730 String contentStr = indexContent.substring(offset, end); 2679 String contentStr = indexContent.substring(offset, end);
2731 JUnitTestCase.assertEquals(identifier.name, contentStr); 2680 expect(contentStr, identifier.name);
2732 } 2681 }
2733 // done 2682 // done
2734 return identifier; 2683 return identifier;
2735 } 2684 }
2736 2685
2737 /** 2686 /**
2738 * Returns the [SimpleIdentifier] at the given search pattern, or `null` if no t found. 2687 * Returns the [SimpleIdentifier] at the given search pattern, or `null` if no t found.
2739 */ 2688 */
2740 SimpleIdentifier findIdentifierMaybe(String search) { 2689 SimpleIdentifier findIdentifierMaybe(String search) {
2741 return findExpression( 2690 return findExpression(
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 static Element findElement2(Element root, String name) { 3001 static Element findElement2(Element root, String name) {
3053 return findElement(root, null, name); 3002 return findElement(root, null, name);
3054 } 3003 }
3055 3004
3056 /** 3005 /**
3057 * @return the offset of given <code>search</code> string in <code>content</co de>. Fails test if 3006 * @return the offset of given <code>search</code> string in <code>content</co de>. Fails test if
3058 * not found. 3007 * not found.
3059 */ 3008 */
3060 static int findOffset(String content, String search) { 3009 static int findOffset(String content, String search) {
3061 int offset = content.indexOf(search); 3010 int offset = content.indexOf(search);
3062 _ut.expect(offset, _ut.isNot(-1)); 3011 expect(offset, isNot(-1));
3063 return offset; 3012 return offset;
3064 } 3013 }
3065 } 3014 }
3066 3015
3067 3016
3068 class ConstantEvaluatorTest extends ResolverTestCase { 3017 class ConstantEvaluatorTest extends ResolverTestCase {
3069 void fail_constructor() { 3018 void fail_constructor() {
3070 EvaluationResult result = _getExpressionValue("?"); 3019 EvaluationResult result = _getExpressionValue("?");
3071 JUnitTestCase.assertTrue(result.isValid); 3020 expect(result.isValid, isTrue);
3072 DartObject value = result.value; 3021 DartObject value = result.value;
3073 JUnitTestCase.assertEquals(null, value); 3022 expect(value, null);
3074 } 3023 }
3075 3024
3076 void fail_identifier_class() { 3025 void fail_identifier_class() {
3077 EvaluationResult result = _getExpressionValue("?"); 3026 EvaluationResult result = _getExpressionValue("?");
3078 JUnitTestCase.assertTrue(result.isValid); 3027 expect(result.isValid, isTrue);
3079 DartObject value = result.value; 3028 DartObject value = result.value;
3080 JUnitTestCase.assertEquals(null, value); 3029 expect(value, null);
3081 } 3030 }
3082 3031
3083 void fail_identifier_function() { 3032 void fail_identifier_function() {
3084 EvaluationResult result = _getExpressionValue("?"); 3033 EvaluationResult result = _getExpressionValue("?");
3085 JUnitTestCase.assertTrue(result.isValid); 3034 expect(result.isValid, isTrue);
3086 DartObject value = result.value; 3035 DartObject value = result.value;
3087 JUnitTestCase.assertEquals(null, value); 3036 expect(value, null);
3088 } 3037 }
3089 3038
3090 void fail_identifier_static() { 3039 void fail_identifier_static() {
3091 EvaluationResult result = _getExpressionValue("?"); 3040 EvaluationResult result = _getExpressionValue("?");
3092 JUnitTestCase.assertTrue(result.isValid); 3041 expect(result.isValid, isTrue);
3093 DartObject value = result.value; 3042 DartObject value = result.value;
3094 JUnitTestCase.assertEquals(null, value); 3043 expect(value, null);
3095 } 3044 }
3096 3045
3097 void fail_identifier_staticMethod() { 3046 void fail_identifier_staticMethod() {
3098 EvaluationResult result = _getExpressionValue("?"); 3047 EvaluationResult result = _getExpressionValue("?");
3099 JUnitTestCase.assertTrue(result.isValid); 3048 expect(result.isValid, isTrue);
3100 DartObject value = result.value; 3049 DartObject value = result.value;
3101 JUnitTestCase.assertEquals(null, value); 3050 expect(value, null);
3102 } 3051 }
3103 3052
3104 void fail_identifier_topLevel() { 3053 void fail_identifier_topLevel() {
3105 EvaluationResult result = _getExpressionValue("?"); 3054 EvaluationResult result = _getExpressionValue("?");
3106 JUnitTestCase.assertTrue(result.isValid); 3055 expect(result.isValid, isTrue);
3107 DartObject value = result.value; 3056 DartObject value = result.value;
3108 JUnitTestCase.assertEquals(null, value); 3057 expect(value, null);
3109 } 3058 }
3110 3059
3111 void fail_identifier_typeParameter() { 3060 void fail_identifier_typeParameter() {
3112 EvaluationResult result = _getExpressionValue("?"); 3061 EvaluationResult result = _getExpressionValue("?");
3113 JUnitTestCase.assertTrue(result.isValid); 3062 expect(result.isValid, isTrue);
3114 DartObject value = result.value; 3063 DartObject value = result.value;
3115 JUnitTestCase.assertEquals(null, value); 3064 expect(value, null);
3116 } 3065 }
3117 3066
3118 void fail_plus_string_string() { 3067 void fail_plus_string_string() {
3119 _assertValue4("ab", "'a' + 'b'"); 3068 _assertValue4("ab", "'a' + 'b'");
3120 } 3069 }
3121 3070
3122 void fail_prefixedIdentifier_invalid() { 3071 void fail_prefixedIdentifier_invalid() {
3123 EvaluationResult result = _getExpressionValue("?"); 3072 EvaluationResult result = _getExpressionValue("?");
3124 JUnitTestCase.assertTrue(result.isValid); 3073 expect(result.isValid, isTrue);
3125 DartObject value = result.value; 3074 DartObject value = result.value;
3126 JUnitTestCase.assertEquals(null, value); 3075 expect(value, null);
3127 } 3076 }
3128 3077
3129 void fail_prefixedIdentifier_valid() { 3078 void fail_prefixedIdentifier_valid() {
3130 EvaluationResult result = _getExpressionValue("?"); 3079 EvaluationResult result = _getExpressionValue("?");
3131 JUnitTestCase.assertTrue(result.isValid); 3080 expect(result.isValid, isTrue);
3132 DartObject value = result.value; 3081 DartObject value = result.value;
3133 JUnitTestCase.assertEquals(null, value); 3082 expect(value, null);
3134 } 3083 }
3135 3084
3136 void fail_propertyAccess_invalid() { 3085 void fail_propertyAccess_invalid() {
3137 EvaluationResult result = _getExpressionValue("?"); 3086 EvaluationResult result = _getExpressionValue("?");
3138 JUnitTestCase.assertTrue(result.isValid); 3087 expect(result.isValid, isTrue);
3139 DartObject value = result.value; 3088 DartObject value = result.value;
3140 JUnitTestCase.assertEquals(null, value); 3089 expect(value, null);
3141 } 3090 }
3142 3091
3143 void fail_propertyAccess_valid() { 3092 void fail_propertyAccess_valid() {
3144 EvaluationResult result = _getExpressionValue("?"); 3093 EvaluationResult result = _getExpressionValue("?");
3145 JUnitTestCase.assertTrue(result.isValid); 3094 expect(result.isValid, isTrue);
3146 DartObject value = result.value; 3095 DartObject value = result.value;
3147 JUnitTestCase.assertEquals(null, value); 3096 expect(value, null);
3148 } 3097 }
3149 3098
3150 void fail_simpleIdentifier_invalid() { 3099 void fail_simpleIdentifier_invalid() {
3151 EvaluationResult result = _getExpressionValue("?"); 3100 EvaluationResult result = _getExpressionValue("?");
3152 JUnitTestCase.assertTrue(result.isValid); 3101 expect(result.isValid, isTrue);
3153 DartObject value = result.value; 3102 DartObject value = result.value;
3154 JUnitTestCase.assertEquals(null, value); 3103 expect(value, null);
3155 } 3104 }
3156 3105
3157 void fail_simpleIdentifier_valid() { 3106 void fail_simpleIdentifier_valid() {
3158 EvaluationResult result = _getExpressionValue("?"); 3107 EvaluationResult result = _getExpressionValue("?");
3159 JUnitTestCase.assertTrue(result.isValid); 3108 expect(result.isValid, isTrue);
3160 DartObject value = result.value; 3109 DartObject value = result.value;
3161 JUnitTestCase.assertEquals(null, value); 3110 expect(value, null);
3162 } 3111 }
3163 3112
3164 void fail_stringLength_complex() { 3113 void fail_stringLength_complex() {
3165 _assertValue3(6, "('qwe' + 'rty').length"); 3114 _assertValue3(6, "('qwe' + 'rty').length");
3166 } 3115 }
3167 3116
3168 void fail_stringLength_simple() { 3117 void fail_stringLength_simple() {
3169 _assertValue3(6, "'Dvorak'.length"); 3118 _assertValue3(6, "'Dvorak'.length");
3170 } 3119 }
3171 3120
(...skipping 11 matching lines...) Expand all
3183 3132
3184 void test_bitXor_int_int() { 3133 void test_bitXor_int_int() {
3185 _assertValue3(74 ^ 42, "74 ^ 42"); 3134 _assertValue3(74 ^ 42, "74 ^ 42");
3186 } 3135 }
3187 void test_divide_double_double() { 3136 void test_divide_double_double() {
3188 _assertValue2(3.2 / 2.3, "3.2 / 2.3"); 3137 _assertValue2(3.2 / 2.3, "3.2 / 2.3");
3189 } 3138 }
3190 3139
3191 void test_divide_double_double_byZero() { 3140 void test_divide_double_double_byZero() {
3192 EvaluationResult result = _getExpressionValue("3.2 / 0.0"); 3141 EvaluationResult result = _getExpressionValue("3.2 / 0.0");
3193 JUnitTestCase.assertTrue(result.isValid); 3142 expect(result.isValid, isTrue);
3194 DartObject value = result.value; 3143 DartObject value = result.value;
3195 JUnitTestCase.assertEquals("double", value.type.name); 3144 expect(value.type.name, "double");
3196 JUnitTestCase.assertTrue(value.doubleValue.isInfinite); 3145 expect(value.doubleValue.isInfinite, isTrue);
3197 } 3146 }
3198 3147
3199 void test_divide_int_int() { 3148 void test_divide_int_int() {
3200 _assertValue3(1, "3 / 2"); 3149 _assertValue3(1, "3 / 2");
3201 } 3150 }
3202 3151
3203 void test_divide_int_int_byZero() { 3152 void test_divide_int_int_byZero() {
3204 EvaluationResult result = _getExpressionValue("3 / 0"); 3153 EvaluationResult result = _getExpressionValue("3 / 0");
3205 JUnitTestCase.assertTrue(result.isValid); 3154 expect(result.isValid, isTrue);
3206 } 3155 }
3207 3156
3208 void test_equal_boolean_boolean() { 3157 void test_equal_boolean_boolean() {
3209 _assertValue(false, "true == false"); 3158 _assertValue(false, "true == false");
3210 } 3159 }
3211 3160
3212 void test_equal_int_int() { 3161 void test_equal_int_int() {
3213 _assertValue(false, "2 == 3"); 3162 _assertValue(false, "2 == 3");
3214 } 3163 }
3215 3164
3216 void test_equal_invalidLeft() { 3165 void test_equal_invalidLeft() {
3217 EvaluationResult result = _getExpressionValue("a == 3"); 3166 EvaluationResult result = _getExpressionValue("a == 3");
3218 JUnitTestCase.assertFalse(result.isValid); 3167 expect(result.isValid, isFalse);
3219 } 3168 }
3220 3169
3221 void test_equal_invalidRight() { 3170 void test_equal_invalidRight() {
3222 EvaluationResult result = _getExpressionValue("2 == a"); 3171 EvaluationResult result = _getExpressionValue("2 == a");
3223 JUnitTestCase.assertFalse(result.isValid); 3172 expect(result.isValid, isFalse);
3224 } 3173 }
3225 3174
3226 void test_equal_string_string() { 3175 void test_equal_string_string() {
3227 _assertValue(false, "'a' == 'b'"); 3176 _assertValue(false, "'a' == 'b'");
3228 } 3177 }
3229 3178
3230 void test_greaterThanOrEqual_int_int() { 3179 void test_greaterThanOrEqual_int_int() {
3231 _assertValue(false, "2 >= 3"); 3180 _assertValue(false, "2 >= 3");
3232 } 3181 }
3233 3182
(...skipping 15 matching lines...) Expand all
3249 void test_literal_boolean_false() { 3198 void test_literal_boolean_false() {
3250 _assertValue(false, "false"); 3199 _assertValue(false, "false");
3251 } 3200 }
3252 3201
3253 void test_literal_boolean_true() { 3202 void test_literal_boolean_true() {
3254 _assertValue(true, "true"); 3203 _assertValue(true, "true");
3255 } 3204 }
3256 3205
3257 void test_literal_list() { 3206 void test_literal_list() {
3258 EvaluationResult result = _getExpressionValue("const ['a', 'b', 'c']"); 3207 EvaluationResult result = _getExpressionValue("const ['a', 'b', 'c']");
3259 JUnitTestCase.assertTrue(result.isValid); 3208 expect(result.isValid, isTrue);
3260 } 3209 }
3261 3210
3262 void test_literal_map() { 3211 void test_literal_map() {
3263 EvaluationResult result = 3212 EvaluationResult result =
3264 _getExpressionValue("const {'a' : 'm', 'b' : 'n', 'c' : 'o'}"); 3213 _getExpressionValue("const {'a' : 'm', 'b' : 'n', 'c' : 'o'}");
3265 JUnitTestCase.assertTrue(result.isValid); 3214 expect(result.isValid, isTrue);
3266 } 3215 }
3267 3216
3268 void test_literal_null() { 3217 void test_literal_null() {
3269 EvaluationResult result = _getExpressionValue("null"); 3218 EvaluationResult result = _getExpressionValue("null");
3270 JUnitTestCase.assertTrue(result.isValid); 3219 expect(result.isValid, isTrue);
3271 DartObject value = result.value; 3220 DartObject value = result.value;
3272 JUnitTestCase.assertTrue(value.isNull); 3221 expect(value.isNull, isTrue);
3273 } 3222 }
3274 3223
3275 void test_literal_number_double() { 3224 void test_literal_number_double() {
3276 _assertValue2(3.45, "3.45"); 3225 _assertValue2(3.45, "3.45");
3277 } 3226 }
3278 3227
3279 void test_literal_number_integer() { 3228 void test_literal_number_integer() {
3280 _assertValue3(42, "42"); 3229 _assertValue3(42, "42");
3281 } 3230 }
3282 3231
3283 void test_literal_string_adjacent() { 3232 void test_literal_string_adjacent() {
3284 _assertValue4("abcdef", "'abc' 'def'"); 3233 _assertValue4("abcdef", "'abc' 'def'");
3285 } 3234 }
3286 3235
3287 void test_literal_string_interpolation_invalid() { 3236 void test_literal_string_interpolation_invalid() {
3288 EvaluationResult result = _getExpressionValue("'a\${f()}c'"); 3237 EvaluationResult result = _getExpressionValue("'a\${f()}c'");
3289 JUnitTestCase.assertFalse(result.isValid); 3238 expect(result.isValid, isFalse);
3290 } 3239 }
3291 3240
3292 void test_literal_string_interpolation_valid() { 3241 void test_literal_string_interpolation_valid() {
3293 _assertValue4("a3c", "'a\${3}c'"); 3242 _assertValue4("a3c", "'a\${3}c'");
3294 } 3243 }
3295 3244
3296 void test_literal_string_simple() { 3245 void test_literal_string_simple() {
3297 _assertValue4("abc", "'abc'"); 3246 _assertValue4("abc", "'abc'");
3298 } 3247 }
3299 3248
(...skipping 12 matching lines...) Expand all
3312 void test_minus_double_double() { 3261 void test_minus_double_double() {
3313 _assertValue2(3.2 - 2.3, "3.2 - 2.3"); 3262 _assertValue2(3.2 - 2.3, "3.2 - 2.3");
3314 } 3263 }
3315 3264
3316 void test_minus_int_int() { 3265 void test_minus_int_int() {
3317 _assertValue3(1, "3 - 2"); 3266 _assertValue3(1, "3 - 2");
3318 } 3267 }
3319 3268
3320 void test_negated_boolean() { 3269 void test_negated_boolean() {
3321 EvaluationResult result = _getExpressionValue("-true"); 3270 EvaluationResult result = _getExpressionValue("-true");
3322 JUnitTestCase.assertFalse(result.isValid); 3271 expect(result.isValid, isFalse);
3323 } 3272 }
3324 3273
3325 void test_negated_double() { 3274 void test_negated_double() {
3326 _assertValue2(-42.3, "-42.3"); 3275 _assertValue2(-42.3, "-42.3");
3327 } 3276 }
3328 3277
3329 void test_negated_integer() { 3278 void test_negated_integer() {
3330 _assertValue3(-42, "-42"); 3279 _assertValue3(-42, "-42");
3331 } 3280 }
3332 3281
3333 void test_notEqual_boolean_boolean() { 3282 void test_notEqual_boolean_boolean() {
3334 _assertValue(true, "true != false"); 3283 _assertValue(true, "true != false");
3335 } 3284 }
3336 3285
3337 void test_notEqual_int_int() { 3286 void test_notEqual_int_int() {
3338 _assertValue(true, "2 != 3"); 3287 _assertValue(true, "2 != 3");
3339 } 3288 }
3340 3289
3341 void test_notEqual_invalidLeft() { 3290 void test_notEqual_invalidLeft() {
3342 EvaluationResult result = _getExpressionValue("a != 3"); 3291 EvaluationResult result = _getExpressionValue("a != 3");
3343 JUnitTestCase.assertFalse(result.isValid); 3292 expect(result.isValid, isFalse);
3344 } 3293 }
3345 3294
3346 void test_notEqual_invalidRight() { 3295 void test_notEqual_invalidRight() {
3347 EvaluationResult result = _getExpressionValue("2 != a"); 3296 EvaluationResult result = _getExpressionValue("2 != a");
3348 JUnitTestCase.assertFalse(result.isValid); 3297 expect(result.isValid, isFalse);
3349 } 3298 }
3350 3299
3351 void test_notEqual_string_string() { 3300 void test_notEqual_string_string() {
3352 _assertValue(true, "'a' != 'b'"); 3301 _assertValue(true, "'a' != 'b'");
3353 } 3302 }
3354 3303
3355 void test_parenthesizedExpression() { 3304 void test_parenthesizedExpression() {
3356 _assertValue4("a", "('a')"); 3305 _assertValue4("a", "('a')");
3357 } 3306 }
3358 3307
(...skipping 29 matching lines...) Expand all
3388 _assertValue3(1, "3.2 ~/ 2.3"); 3337 _assertValue3(1, "3.2 ~/ 2.3");
3389 } 3338 }
3390 3339
3391 void test_truncatingDivide_int_int() { 3340 void test_truncatingDivide_int_int() {
3392 _assertValue3(3, "10 ~/ 3"); 3341 _assertValue3(3, "10 ~/ 3");
3393 } 3342 }
3394 3343
3395 void _assertValue(bool expectedValue, String contents) { 3344 void _assertValue(bool expectedValue, String contents) {
3396 EvaluationResult result = _getExpressionValue(contents); 3345 EvaluationResult result = _getExpressionValue(contents);
3397 DartObject value = result.value; 3346 DartObject value = result.value;
3398 JUnitTestCase.assertEquals("bool", value.type.name); 3347 expect(value.type.name, "bool");
3399 JUnitTestCase.assertEquals(expectedValue, value.boolValue); 3348 expect(value.boolValue, expectedValue);
3400 } 3349 }
3401 3350
3402 void _assertValue2(double expectedValue, String contents) { 3351 void _assertValue2(double expectedValue, String contents) {
3403 EvaluationResult result = _getExpressionValue(contents); 3352 EvaluationResult result = _getExpressionValue(contents);
3404 JUnitTestCase.assertTrue(result.isValid); 3353 expect(result.isValid, isTrue);
3405 DartObject value = result.value; 3354 DartObject value = result.value;
3406 JUnitTestCase.assertEquals("double", value.type.name); 3355 expect(value.type.name, "double");
3407 JUnitTestCase.assertEquals(expectedValue, value.doubleValue); 3356 expect(value.doubleValue, expectedValue);
3408 } 3357 }
3409 3358
3410 void _assertValue3(int expectedValue, String contents) { 3359 void _assertValue3(int expectedValue, String contents) {
3411 EvaluationResult result = _getExpressionValue(contents); 3360 EvaluationResult result = _getExpressionValue(contents);
3412 JUnitTestCase.assertTrue(result.isValid); 3361 expect(result.isValid, isTrue);
3413 DartObject value = result.value; 3362 DartObject value = result.value;
3414 JUnitTestCase.assertEquals("int", value.type.name); 3363 expect(value.type.name, "int");
3415 JUnitTestCase.assertEquals(expectedValue, value.intValue); 3364 expect(value.intValue, expectedValue);
3416 } 3365 }
3417 3366
3418 void _assertValue4(String expectedValue, String contents) { 3367 void _assertValue4(String expectedValue, String contents) {
3419 EvaluationResult result = _getExpressionValue(contents); 3368 EvaluationResult result = _getExpressionValue(contents);
3420 DartObject value = result.value; 3369 DartObject value = result.value;
3421 JUnitTestCase.assertNotNull(value); 3370 expect(value, isNotNull);
3422 ParameterizedType type = value.type; 3371 ParameterizedType type = value.type;
3423 JUnitTestCase.assertNotNull(type); 3372 expect(type, isNotNull);
3424 JUnitTestCase.assertEquals("String", type.name); 3373 expect(type.name, "String");
3425 JUnitTestCase.assertEquals(expectedValue, value.stringValue); 3374 expect(value.stringValue, expectedValue);
3426 } 3375 }
3427 3376
3428 EvaluationResult _getExpressionValue(String contents) { 3377 EvaluationResult _getExpressionValue(String contents) {
3429 Source source = addSource("var x = $contents;"); 3378 Source source = addSource("var x = $contents;");
3430 LibraryElement library = resolve(source); 3379 LibraryElement library = resolve(source);
3431 CompilationUnit unit = 3380 CompilationUnit unit =
3432 analysisContext.resolveCompilationUnit(source, library); 3381 analysisContext.resolveCompilationUnit(source, library);
3433 JUnitTestCase.assertNotNull(unit); 3382 expect(unit, isNotNull);
3434 NodeList<CompilationUnitMember> declarations = unit.declarations; 3383 NodeList<CompilationUnitMember> declarations = unit.declarations;
3435 EngineTestCase.assertSizeOfList(1, declarations); 3384 EngineTestCase.assertSizeOfList(1, declarations);
3436 CompilationUnitMember declaration = declarations[0]; 3385 CompilationUnitMember declaration = declarations[0];
3437 EngineTestCase.assertInstanceOf( 3386 EngineTestCase.assertInstanceOf(
3438 (obj) => obj is TopLevelVariableDeclaration, 3387 (obj) => obj is TopLevelVariableDeclaration,
3439 TopLevelVariableDeclaration, 3388 TopLevelVariableDeclaration,
3440 declaration); 3389 declaration);
3441 NodeList<VariableDeclaration> variables = 3390 NodeList<VariableDeclaration> variables =
3442 (declaration as TopLevelVariableDeclaration).variables.variables; 3391 (declaration as TopLevelVariableDeclaration).variables.variables;
3443 EngineTestCase.assertSizeOfList(1, variables); 3392 EngineTestCase.assertSizeOfList(1, variables);
3444 ConstantEvaluator evaluator = new ConstantEvaluator( 3393 ConstantEvaluator evaluator = new ConstantEvaluator(
3445 source, 3394 source,
3446 (analysisContext as AnalysisContextImpl).typeProvider); 3395 (analysisContext as AnalysisContextImpl).typeProvider);
3447 return evaluator.evaluate(variables[0].initializer); 3396 return evaluator.evaluate(variables[0].initializer);
3448 } 3397 }
3449 } 3398 }
3450 3399
3451 3400
3452 class ConstantFinderTest extends EngineTestCase { 3401 class ConstantFinderTest extends EngineTestCase {
3453 AstNode _node; 3402 AstNode _node;
3454 3403
3455 void test_visitConstructorDeclaration_const() { 3404 void test_visitConstructorDeclaration_const() {
3456 ConstructorElement element = _setupConstructorDeclaration("A", true); 3405 ConstructorElement element = _setupConstructorDeclaration("A", true);
3457 JUnitTestCase.assertSame(_node, _findConstantDeclarations()[element]); 3406 expect(_findConstantDeclarations()[element], same(_node));
3458 } 3407 }
3459 3408
3460 void test_visitConstructorDeclaration_nonConst() { 3409 void test_visitConstructorDeclaration_nonConst() {
3461 _setupConstructorDeclaration("A", false); 3410 _setupConstructorDeclaration("A", false);
3462 JUnitTestCase.assertTrue(_findConstantDeclarations().isEmpty); 3411 expect(_findConstantDeclarations().isEmpty, isTrue);
3463 } 3412 }
3464 3413
3465 void test_visitInstanceCreationExpression_const() { 3414 void test_visitInstanceCreationExpression_const() {
3466 _setupInstanceCreationExpression("A", true); 3415 _setupInstanceCreationExpression("A", true);
3467 JUnitTestCase.assertTrue(_findConstructorInvocations().contains(_node)); 3416 expect(_findConstructorInvocations().contains(_node), isTrue);
3468 } 3417 }
3469 3418
3470 void test_visitInstanceCreationExpression_nonConst() { 3419 void test_visitInstanceCreationExpression_nonConst() {
3471 _setupInstanceCreationExpression("A", false); 3420 _setupInstanceCreationExpression("A", false);
3472 JUnitTestCase.assertTrue(_findConstructorInvocations().isEmpty); 3421 expect(_findConstructorInvocations().isEmpty, isTrue);
3473 } 3422 }
3474 3423
3475 void test_visitVariableDeclaration_const() { 3424 void test_visitVariableDeclaration_const() {
3476 VariableElement element = _setupVariableDeclaration("v", true, true); 3425 VariableElement element = _setupVariableDeclaration("v", true, true);
3477 JUnitTestCase.assertSame(_node, _findVariableDeclarations()[element]); 3426 expect(_findVariableDeclarations()[element], same(_node));
3478 } 3427 }
3479 3428
3480 void test_visitVariableDeclaration_noInitializer() { 3429 void test_visitVariableDeclaration_noInitializer() {
3481 _setupVariableDeclaration("v", true, false); 3430 _setupVariableDeclaration("v", true, false);
3482 JUnitTestCase.assertTrue(_findVariableDeclarations().isEmpty); 3431 expect(_findVariableDeclarations().isEmpty, isTrue);
3483 } 3432 }
3484 3433
3485 void test_visitVariableDeclaration_nonConst() { 3434 void test_visitVariableDeclaration_nonConst() {
3486 _setupVariableDeclaration("v", false, true); 3435 _setupVariableDeclaration("v", false, true);
3487 JUnitTestCase.assertTrue(_findVariableDeclarations().isEmpty); 3436 expect(_findVariableDeclarations().isEmpty, isTrue);
3488 } 3437 }
3489 3438
3490 Map<ConstructorElement, ConstructorDeclaration> _findConstantDeclarations() { 3439 Map<ConstructorElement, ConstructorDeclaration> _findConstantDeclarations() {
3491 ConstantFinder finder = new ConstantFinder(); 3440 ConstantFinder finder = new ConstantFinder();
3492 _node.accept(finder); 3441 _node.accept(finder);
3493 Map<ConstructorElement, ConstructorDeclaration> constructorMap = 3442 Map<ConstructorElement, ConstructorDeclaration> constructorMap =
3494 finder.constructorMap; 3443 finder.constructorMap;
3495 JUnitTestCase.assertNotNull(constructorMap); 3444 expect(constructorMap, isNotNull);
3496 return constructorMap; 3445 return constructorMap;
3497 } 3446 }
3498 3447
3499 List<InstanceCreationExpression> _findConstructorInvocations() { 3448 List<InstanceCreationExpression> _findConstructorInvocations() {
3500 ConstantFinder finder = new ConstantFinder(); 3449 ConstantFinder finder = new ConstantFinder();
3501 _node.accept(finder); 3450 _node.accept(finder);
3502 List<InstanceCreationExpression> constructorInvocations = 3451 List<InstanceCreationExpression> constructorInvocations =
3503 finder.constructorInvocations; 3452 finder.constructorInvocations;
3504 JUnitTestCase.assertNotNull(constructorInvocations); 3453 expect(constructorInvocations, isNotNull);
3505 return constructorInvocations; 3454 return constructorInvocations;
3506 } 3455 }
3507 3456
3508 Map<VariableElement, VariableDeclaration> _findVariableDeclarations() { 3457 Map<VariableElement, VariableDeclaration> _findVariableDeclarations() {
3509 ConstantFinder finder = new ConstantFinder(); 3458 ConstantFinder finder = new ConstantFinder();
3510 _node.accept(finder); 3459 _node.accept(finder);
3511 Map<VariableElement, VariableDeclaration> variableMap = finder.variableMap; 3460 Map<VariableElement, VariableDeclaration> variableMap = finder.variableMap;
3512 JUnitTestCase.assertNotNull(variableMap); 3461 expect(variableMap, isNotNull);
3513 return variableMap; 3462 return variableMap;
3514 } 3463 }
3515 3464
3516 ConstructorElement _setupConstructorDeclaration(String name, bool isConst) { 3465 ConstructorElement _setupConstructorDeclaration(String name, bool isConst) {
3517 Keyword constKeyword = isConst ? Keyword.CONST : null; 3466 Keyword constKeyword = isConst ? Keyword.CONST : null;
3518 ConstructorDeclaration constructorDeclaration = 3467 ConstructorDeclaration constructorDeclaration =
3519 AstFactory.constructorDeclaration2( 3468 AstFactory.constructorDeclaration2(
3520 constKeyword, 3469 constKeyword,
3521 null, 3470 null,
3522 null, 3471 null,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 TestLogger logger = new TestLogger(); 3510 TestLogger logger = new TestLogger();
3562 AnalysisEngine.instance.logger = logger; 3511 AnalysisEngine.instance.logger = logger;
3563 Source librarySource = addSource(r''' 3512 Source librarySource = addSource(r'''
3564 const int a = c; 3513 const int a = c;
3565 const int b = a; 3514 const int b = a;
3566 const int c = b;'''); 3515 const int c = b;''');
3567 LibraryElement libraryElement = resolve(librarySource); 3516 LibraryElement libraryElement = resolve(librarySource);
3568 CompilationUnit unit = 3517 CompilationUnit unit =
3569 analysisContext.resolveCompilationUnit(librarySource, libraryElement); 3518 analysisContext.resolveCompilationUnit(librarySource, libraryElement);
3570 analysisContext.computeErrors(librarySource); 3519 analysisContext.computeErrors(librarySource);
3571 JUnitTestCase.assertNotNull(unit); 3520 expect(unit, isNotNull);
3572 ConstantValueComputer computer = _makeConstantValueComputer(); 3521 ConstantValueComputer computer = _makeConstantValueComputer();
3573 computer.add(unit); 3522 computer.add(unit);
3574 computer.computeValues(); 3523 computer.computeValues();
3575 NodeList<CompilationUnitMember> members = unit.declarations; 3524 NodeList<CompilationUnitMember> members = unit.declarations;
3576 EngineTestCase.assertSizeOfList(3, members); 3525 EngineTestCase.assertSizeOfList(3, members);
3577 _validate(false, (members[0] as TopLevelVariableDeclaration).variables); 3526 _validate(false, (members[0] as TopLevelVariableDeclaration).variables);
3578 _validate(false, (members[1] as TopLevelVariableDeclaration).variables); 3527 _validate(false, (members[1] as TopLevelVariableDeclaration).variables);
3579 _validate(false, (members[2] as TopLevelVariableDeclaration).variables); 3528 _validate(false, (members[2] as TopLevelVariableDeclaration).variables);
3580 } 3529 }
3581 3530
3582 void test_computeValues_dependentVariables() { 3531 void test_computeValues_dependentVariables() {
3583 Source librarySource = addSource(r''' 3532 Source librarySource = addSource(r'''
3584 const int b = a; 3533 const int b = a;
3585 const int a = 0;'''); 3534 const int a = 0;''');
3586 LibraryElement libraryElement = resolve(librarySource); 3535 LibraryElement libraryElement = resolve(librarySource);
3587 CompilationUnit unit = 3536 CompilationUnit unit =
3588 analysisContext.resolveCompilationUnit(librarySource, libraryElement); 3537 analysisContext.resolveCompilationUnit(librarySource, libraryElement);
3589 JUnitTestCase.assertNotNull(unit); 3538 expect(unit, isNotNull);
3590 ConstantValueComputer computer = _makeConstantValueComputer(); 3539 ConstantValueComputer computer = _makeConstantValueComputer();
3591 computer.add(unit); 3540 computer.add(unit);
3592 computer.computeValues(); 3541 computer.computeValues();
3593 NodeList<CompilationUnitMember> members = unit.declarations; 3542 NodeList<CompilationUnitMember> members = unit.declarations;
3594 EngineTestCase.assertSizeOfList(2, members); 3543 EngineTestCase.assertSizeOfList(2, members);
3595 _validate(true, (members[0] as TopLevelVariableDeclaration).variables); 3544 _validate(true, (members[0] as TopLevelVariableDeclaration).variables);
3596 _validate(true, (members[1] as TopLevelVariableDeclaration).variables); 3545 _validate(true, (members[1] as TopLevelVariableDeclaration).variables);
3597 } 3546 }
3598 3547
3599 void test_computeValues_empty() { 3548 void test_computeValues_empty() {
(...skipping 11 matching lines...) Expand all
3611 const int a = 0;'''); 3560 const int a = 0;''');
3612 Source partSource = addNamedSource( 3561 Source partSource = addNamedSource(
3613 "/part.dart", 3562 "/part.dart",
3614 r''' 3563 r'''
3615 part of lib; 3564 part of lib;
3616 const int b = a; 3565 const int b = a;
3617 const int d = c;'''); 3566 const int d = c;''');
3618 LibraryElement libraryElement = resolve(librarySource); 3567 LibraryElement libraryElement = resolve(librarySource);
3619 CompilationUnit libraryUnit = 3568 CompilationUnit libraryUnit =
3620 analysisContext.resolveCompilationUnit(librarySource, libraryElement); 3569 analysisContext.resolveCompilationUnit(librarySource, libraryElement);
3621 JUnitTestCase.assertNotNull(libraryUnit); 3570 expect(libraryUnit, isNotNull);
3622 CompilationUnit partUnit = 3571 CompilationUnit partUnit =
3623 analysisContext.resolveCompilationUnit(partSource, libraryElement); 3572 analysisContext.resolveCompilationUnit(partSource, libraryElement);
3624 JUnitTestCase.assertNotNull(partUnit); 3573 expect(partUnit, isNotNull);
3625 ConstantValueComputer computer = _makeConstantValueComputer(); 3574 ConstantValueComputer computer = _makeConstantValueComputer();
3626 computer.add(libraryUnit); 3575 computer.add(libraryUnit);
3627 computer.add(partUnit); 3576 computer.add(partUnit);
3628 computer.computeValues(); 3577 computer.computeValues();
3629 NodeList<CompilationUnitMember> libraryMembers = libraryUnit.declarations; 3578 NodeList<CompilationUnitMember> libraryMembers = libraryUnit.declarations;
3630 EngineTestCase.assertSizeOfList(2, libraryMembers); 3579 EngineTestCase.assertSizeOfList(2, libraryMembers);
3631 _validate( 3580 _validate(
3632 true, 3581 true,
3633 (libraryMembers[0] as TopLevelVariableDeclaration).variables); 3582 (libraryMembers[0] as TopLevelVariableDeclaration).variables);
3634 _validate( 3583 _validate(
3635 true, 3584 true,
3636 (libraryMembers[1] as TopLevelVariableDeclaration).variables); 3585 (libraryMembers[1] as TopLevelVariableDeclaration).variables);
3637 NodeList<CompilationUnitMember> partMembers = libraryUnit.declarations; 3586 NodeList<CompilationUnitMember> partMembers = libraryUnit.declarations;
3638 EngineTestCase.assertSizeOfList(2, partMembers); 3587 EngineTestCase.assertSizeOfList(2, partMembers);
3639 _validate(true, (partMembers[0] as TopLevelVariableDeclaration).variables); 3588 _validate(true, (partMembers[0] as TopLevelVariableDeclaration).variables);
3640 _validate(true, (partMembers[1] as TopLevelVariableDeclaration).variables); 3589 _validate(true, (partMembers[1] as TopLevelVariableDeclaration).variables);
3641 } 3590 }
3642 3591
3643 void test_computeValues_singleVariable() { 3592 void test_computeValues_singleVariable() {
3644 Source librarySource = addSource("const int a = 0;"); 3593 Source librarySource = addSource("const int a = 0;");
3645 LibraryElement libraryElement = resolve(librarySource); 3594 LibraryElement libraryElement = resolve(librarySource);
3646 CompilationUnit unit = 3595 CompilationUnit unit =
3647 analysisContext.resolveCompilationUnit(librarySource, libraryElement); 3596 analysisContext.resolveCompilationUnit(librarySource, libraryElement);
3648 JUnitTestCase.assertNotNull(unit); 3597 expect(unit, isNotNull);
3649 ConstantValueComputer computer = _makeConstantValueComputer(); 3598 ConstantValueComputer computer = _makeConstantValueComputer();
3650 computer.add(unit); 3599 computer.add(unit);
3651 computer.computeValues(); 3600 computer.computeValues();
3652 NodeList<CompilationUnitMember> members = unit.declarations; 3601 NodeList<CompilationUnitMember> members = unit.declarations;
3653 EngineTestCase.assertSizeOfList(1, members); 3602 EngineTestCase.assertSizeOfList(1, members);
3654 _validate(true, (members[0] as TopLevelVariableDeclaration).variables); 3603 _validate(true, (members[0] as TopLevelVariableDeclaration).variables);
3655 } 3604 }
3656 3605
3657 void test_dependencyOnConstructor() { 3606 void test_dependencyOnConstructor() {
3658 // x depends on "const A()" 3607 // x depends on "const A()"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 3802
3854 void test_dependencyOnVariable() { 3803 void test_dependencyOnVariable() {
3855 // x depends on y 3804 // x depends on y
3856 _assertProperDependencies(r''' 3805 _assertProperDependencies(r'''
3857 const x = y + 1; 3806 const x = y + 1;
3858 const y = 2;''', 3807 const y = 2;''',
3859 []); 3808 []);
3860 } 3809 }
3861 3810
3862 void test_fromEnvironment_bool_default_false() { 3811 void test_fromEnvironment_bool_default_false() {
3863 JUnitTestCase.assertEquals( 3812 expect(_assertValidBool(_check_fromEnvironment_bool(null, "false")), false);
3864 false,
3865 _assertValidBool(_check_fromEnvironment_bool(null, "false")));
3866 } 3813 }
3867 3814
3868 void test_fromEnvironment_bool_default_overridden() { 3815 void test_fromEnvironment_bool_default_overridden() {
3869 JUnitTestCase.assertEquals( 3816 expect(_assertValidBool(_check_fromEnvironment_bool("false", "true")), false );
3870 false,
3871 _assertValidBool(_check_fromEnvironment_bool("false", "true")));
3872 } 3817 }
3873 3818
3874 void test_fromEnvironment_bool_default_parseError() { 3819 void test_fromEnvironment_bool_default_parseError() {
3875 JUnitTestCase.assertEquals( 3820 expect(_assertValidBool(_check_fromEnvironment_bool("parseError", "true")), true);
3876 true,
3877 _assertValidBool(_check_fromEnvironment_bool("parseError", "true")));
3878 } 3821 }
3879 3822
3880 void test_fromEnvironment_bool_default_true() { 3823 void test_fromEnvironment_bool_default_true() {
3881 JUnitTestCase.assertEquals( 3824 expect(_assertValidBool(_check_fromEnvironment_bool(null, "true")), true);
3882 true,
3883 _assertValidBool(_check_fromEnvironment_bool(null, "true")));
3884 } 3825 }
3885 3826
3886 void test_fromEnvironment_bool_false() { 3827 void test_fromEnvironment_bool_false() {
3887 JUnitTestCase.assertEquals( 3828 expect(_assertValidBool(_check_fromEnvironment_bool("false", null)), false);
3888 false,
3889 _assertValidBool(_check_fromEnvironment_bool("false", null)));
3890 } 3829 }
3891 3830
3892 void test_fromEnvironment_bool_parseError() { 3831 void test_fromEnvironment_bool_parseError() {
3893 JUnitTestCase.assertEquals( 3832 expect(_assertValidBool(_check_fromEnvironment_bool("parseError", null)), fa lse);
3894 false,
3895 _assertValidBool(_check_fromEnvironment_bool("parseError", null)));
3896 } 3833 }
3897 3834
3898 void test_fromEnvironment_bool_true() { 3835 void test_fromEnvironment_bool_true() {
3899 JUnitTestCase.assertEquals( 3836 expect(_assertValidBool(_check_fromEnvironment_bool("true", null)), true);
3900 true,
3901 _assertValidBool(_check_fromEnvironment_bool("true", null)));
3902 } 3837 }
3903 3838
3904 void test_fromEnvironment_bool_undeclared() { 3839 void test_fromEnvironment_bool_undeclared() {
3905 _assertValidUnknown(_check_fromEnvironment_bool(null, null)); 3840 _assertValidUnknown(_check_fromEnvironment_bool(null, null));
3906 } 3841 }
3907 3842
3908 void test_fromEnvironment_int_default_overridden() { 3843 void test_fromEnvironment_int_default_overridden() {
3909 JUnitTestCase.assertEquals( 3844 expect(_assertValidInt(_check_fromEnvironment_int("234", "123")), 234);
3910 234,
3911 _assertValidInt(_check_fromEnvironment_int("234", "123")));
3912 } 3845 }
3913 3846
3914 void test_fromEnvironment_int_default_parseError() { 3847 void test_fromEnvironment_int_default_parseError() {
3915 JUnitTestCase.assertEquals( 3848 expect(_assertValidInt(_check_fromEnvironment_int("parseError", "123")), 123 );
3916 123,
3917 _assertValidInt(_check_fromEnvironment_int("parseError", "123")));
3918 } 3849 }
3919 3850
3920 void test_fromEnvironment_int_default_undeclared() { 3851 void test_fromEnvironment_int_default_undeclared() {
3921 JUnitTestCase.assertEquals( 3852 expect(_assertValidInt(_check_fromEnvironment_int(null, "123")), 123);
3922 123,
3923 _assertValidInt(_check_fromEnvironment_int(null, "123")));
3924 } 3853 }
3925 3854
3926 void test_fromEnvironment_int_ok() { 3855 void test_fromEnvironment_int_ok() {
3927 JUnitTestCase.assertEquals( 3856 expect(_assertValidInt(_check_fromEnvironment_int("234", null)), 234);
3928 234,
3929 _assertValidInt(_check_fromEnvironment_int("234", null)));
3930 } 3857 }
3931 3858
3932 void test_fromEnvironment_int_parseError() { 3859 void test_fromEnvironment_int_parseError() {
3933 _assertValidNull(_check_fromEnvironment_int("parseError", null)); 3860 _assertValidNull(_check_fromEnvironment_int("parseError", null));
3934 } 3861 }
3935 3862
3936 void test_fromEnvironment_int_parseError_nullDefault() { 3863 void test_fromEnvironment_int_parseError_nullDefault() {
3937 _assertValidNull(_check_fromEnvironment_int("parseError", "null")); 3864 _assertValidNull(_check_fromEnvironment_int("parseError", "null"));
3938 } 3865 }
3939 3866
3940 void test_fromEnvironment_int_undeclared() { 3867 void test_fromEnvironment_int_undeclared() {
3941 _assertValidUnknown(_check_fromEnvironment_int(null, null)); 3868 _assertValidUnknown(_check_fromEnvironment_int(null, null));
3942 } 3869 }
3943 3870
3944 void test_fromEnvironment_int_undeclared_nullDefault() { 3871 void test_fromEnvironment_int_undeclared_nullDefault() {
3945 _assertValidNull(_check_fromEnvironment_int(null, "null")); 3872 _assertValidNull(_check_fromEnvironment_int(null, "null"));
3946 } 3873 }
3947 3874
3948 void test_fromEnvironment_string_default_overridden() { 3875 void test_fromEnvironment_string_default_overridden() {
3949 JUnitTestCase.assertEquals( 3876 expect(_assertValidString(_check_fromEnvironment_string("abc", "'def'")), "a bc");
3950 "abc",
3951 _assertValidString(_check_fromEnvironment_string("abc", "'def'")));
3952 } 3877 }
3953 3878
3954 void test_fromEnvironment_string_default_undeclared() { 3879 void test_fromEnvironment_string_default_undeclared() {
3955 JUnitTestCase.assertEquals( 3880 expect(_assertValidString(_check_fromEnvironment_string(null, "'def'")), "de f");
3956 "def",
3957 _assertValidString(_check_fromEnvironment_string(null, "'def'")));
3958 } 3881 }
3959 3882
3960 void test_fromEnvironment_string_empty() { 3883 void test_fromEnvironment_string_empty() {
3961 JUnitTestCase.assertEquals( 3884 expect(_assertValidString(_check_fromEnvironment_string("", null)), "");
3962 "",
3963 _assertValidString(_check_fromEnvironment_string("", null)));
3964 } 3885 }
3965 3886
3966 void test_fromEnvironment_string_ok() { 3887 void test_fromEnvironment_string_ok() {
3967 JUnitTestCase.assertEquals( 3888 expect(_assertValidString(_check_fromEnvironment_string("abc", null)), "abc" );
3968 "abc",
3969 _assertValidString(_check_fromEnvironment_string("abc", null)));
3970 } 3889 }
3971 3890
3972 void test_fromEnvironment_string_undeclared() { 3891 void test_fromEnvironment_string_undeclared() {
3973 _assertValidUnknown(_check_fromEnvironment_string(null, null)); 3892 _assertValidUnknown(_check_fromEnvironment_string(null, null));
3974 } 3893 }
3975 3894
3976 void test_fromEnvironment_string_undeclared_nullDefault() { 3895 void test_fromEnvironment_string_undeclared_nullDefault() {
3977 _assertValidNull(_check_fromEnvironment_string(null, "null")); 3896 _assertValidNull(_check_fromEnvironment_string(null, "null"));
3978 } 3897 }
3979 3898
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
4332 }'''); 4251 }''');
4333 _assertValidUnknown( 4252 _assertValidUnknown(
4334 _evaluateInstanceCreationExpression(compilationUnit, "foo")); 4253 _evaluateInstanceCreationExpression(compilationUnit, "foo"));
4335 } 4254 }
4336 4255
4337 void test_instanceCreationExpression_symbol() { 4256 void test_instanceCreationExpression_symbol() {
4338 CompilationUnit compilationUnit = 4257 CompilationUnit compilationUnit =
4339 resolveSource("const foo = const Symbol('a');"); 4258 resolveSource("const foo = const Symbol('a');");
4340 EvaluationResultImpl evaluationResult = 4259 EvaluationResultImpl evaluationResult =
4341 _evaluateInstanceCreationExpression(compilationUnit, "foo"); 4260 _evaluateInstanceCreationExpression(compilationUnit, "foo");
4342 JUnitTestCase.assertNotNull(evaluationResult.value); 4261 expect(evaluationResult.value, isNotNull);
4343 DartObjectImpl value = evaluationResult.value; 4262 DartObjectImpl value = evaluationResult.value;
4344 JUnitTestCase.assertEquals(typeProvider.symbolType, value.type); 4263 expect(value.type, typeProvider.symbolType);
4345 JUnitTestCase.assertEquals("a", value.value); 4264 expect(value.value, "a");
4346 } 4265 }
4347 4266
4348 void test_instanceCreationExpression_withSupertypeParams_explicit() { 4267 void test_instanceCreationExpression_withSupertypeParams_explicit() {
4349 _checkInstanceCreation_withSupertypeParams(true); 4268 _checkInstanceCreation_withSupertypeParams(true);
4350 } 4269 }
4351 4270
4352 void test_instanceCreationExpression_withSupertypeParams_implicit() { 4271 void test_instanceCreationExpression_withSupertypeParams_implicit() {
4353 _checkInstanceCreation_withSupertypeParams(false); 4272 _checkInstanceCreation_withSupertypeParams(false);
4354 } 4273 }
4355 4274
4356 void test_instanceCreationExpression_withTypeParams() { 4275 void test_instanceCreationExpression_withTypeParams() {
4357 CompilationUnit compilationUnit = resolveSource(r''' 4276 CompilationUnit compilationUnit = resolveSource(r'''
4358 class C<E> { 4277 class C<E> {
4359 const C(); 4278 const C();
4360 } 4279 }
4361 const c_int = const C<int>(); 4280 const c_int = const C<int>();
4362 const c_num = const C<num>();'''); 4281 const c_num = const C<num>();''');
4363 EvaluationResultImpl c_int = 4282 EvaluationResultImpl c_int =
4364 _evaluateInstanceCreationExpression(compilationUnit, "c_int"); 4283 _evaluateInstanceCreationExpression(compilationUnit, "c_int");
4365 _assertType(c_int, "C<int>"); 4284 _assertType(c_int, "C<int>");
4366 DartObjectImpl c_int_value = c_int.value; 4285 DartObjectImpl c_int_value = c_int.value;
4367 EvaluationResultImpl c_num = 4286 EvaluationResultImpl c_num =
4368 _evaluateInstanceCreationExpression(compilationUnit, "c_num"); 4287 _evaluateInstanceCreationExpression(compilationUnit, "c_num");
4369 _assertType(c_num, "C<num>"); 4288 _assertType(c_num, "C<num>");
4370 DartObjectImpl c_num_value = c_num.value; 4289 DartObjectImpl c_num_value = c_num.value;
4371 JUnitTestCase.assertFalse(c_int_value == c_num_value); 4290 expect(c_int_value == c_num_value, isFalse);
4372 } 4291 }
4373 4292
4374 void test_isValidSymbol() { 4293 void test_isValidSymbol() {
4375 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("")); 4294 expect(ConstantValueComputer.isValidPublicSymbol(""), isTrue);
4376 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("foo")); 4295 expect(ConstantValueComputer.isValidPublicSymbol("foo"), isTrue);
4377 JUnitTestCase.assertTrue( 4296 expect(ConstantValueComputer.isValidPublicSymbol("foo.bar"), isTrue);
4378 ConstantValueComputer.isValidPublicSymbol("foo.bar")); 4297 expect(ConstantValueComputer.isValidPublicSymbol("foo\$"), isTrue);
4379 JUnitTestCase.assertTrue( 4298 expect(ConstantValueComputer.isValidPublicSymbol("foo\$bar"), isTrue);
4380 ConstantValueComputer.isValidPublicSymbol("foo\$")); 4299 expect(ConstantValueComputer.isValidPublicSymbol("iff"), isTrue);
4381 JUnitTestCase.assertTrue( 4300 expect(ConstantValueComputer.isValidPublicSymbol("gif"), isTrue);
4382 ConstantValueComputer.isValidPublicSymbol("foo\$bar")); 4301 expect(ConstantValueComputer.isValidPublicSymbol("if\$"), isTrue);
4383 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("iff")); 4302 expect(ConstantValueComputer.isValidPublicSymbol("\$if"), isTrue);
4384 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("gif")); 4303 expect(ConstantValueComputer.isValidPublicSymbol("foo="), isTrue);
4385 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("if\$")); 4304 expect(ConstantValueComputer.isValidPublicSymbol("foo.bar="), isTrue);
4386 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("\$if")); 4305 expect(ConstantValueComputer.isValidPublicSymbol("foo.+"), isTrue);
4387 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("foo=")); 4306 expect(ConstantValueComputer.isValidPublicSymbol("void"), isTrue);
4388 JUnitTestCase.assertTrue( 4307 expect(ConstantValueComputer.isValidPublicSymbol("_foo"), isFalse);
4389 ConstantValueComputer.isValidPublicSymbol("foo.bar=")); 4308 expect(ConstantValueComputer.isValidPublicSymbol("_foo.bar"), isFalse);
4390 JUnitTestCase.assertTrue( 4309 expect(ConstantValueComputer.isValidPublicSymbol("foo._bar"), isFalse);
4391 ConstantValueComputer.isValidPublicSymbol("foo.+")); 4310 expect(ConstantValueComputer.isValidPublicSymbol("if"), isFalse);
4392 JUnitTestCase.assertTrue(ConstantValueComputer.isValidPublicSymbol("void")); 4311 expect(ConstantValueComputer.isValidPublicSymbol("if.foo"), isFalse);
4393 JUnitTestCase.assertFalse( 4312 expect(ConstantValueComputer.isValidPublicSymbol("foo.if"), isFalse);
4394 ConstantValueComputer.isValidPublicSymbol("_foo")); 4313 expect(ConstantValueComputer.isValidPublicSymbol("foo=.bar"), isFalse);
4395 JUnitTestCase.assertFalse( 4314 expect(ConstantValueComputer.isValidPublicSymbol("foo."), isFalse);
4396 ConstantValueComputer.isValidPublicSymbol("_foo.bar")); 4315 expect(ConstantValueComputer.isValidPublicSymbol("+.foo"), isFalse);
4397 JUnitTestCase.assertFalse( 4316 expect(ConstantValueComputer.isValidPublicSymbol("void.foo"), isFalse);
4398 ConstantValueComputer.isValidPublicSymbol("foo._bar")); 4317 expect(ConstantValueComputer.isValidPublicSymbol("foo.void"), isFalse);
4399 JUnitTestCase.assertFalse(ConstantValueComputer.isValidPublicSymbol("if"));
4400 JUnitTestCase.assertFalse(
4401 ConstantValueComputer.isValidPublicSymbol("if.foo"));
4402 JUnitTestCase.assertFalse(
4403 ConstantValueComputer.isValidPublicSymbol("foo.if"));
4404 JUnitTestCase.assertFalse(
4405 ConstantValueComputer.isValidPublicSymbol("foo=.bar"));
4406 JUnitTestCase.assertFalse(
4407 ConstantValueComputer.isValidPublicSymbol("foo."));
4408 JUnitTestCase.assertFalse(
4409 ConstantValueComputer.isValidPublicSymbol("+.foo"));
4410 JUnitTestCase.assertFalse(
4411 ConstantValueComputer.isValidPublicSymbol("void.foo"));
4412 JUnitTestCase.assertFalse(
4413 ConstantValueComputer.isValidPublicSymbol("foo.void"));
4414 } 4318 }
4415 4319
4416 void test_symbolLiteral_void() { 4320 void test_symbolLiteral_void() {
4417 CompilationUnit compilationUnit = 4321 CompilationUnit compilationUnit =
4418 resolveSource("const voidSymbol = #void;"); 4322 resolveSource("const voidSymbol = #void;");
4419 VariableDeclaration voidSymbol = 4323 VariableDeclaration voidSymbol =
4420 findTopLevelDeclaration(compilationUnit, "voidSymbol"); 4324 findTopLevelDeclaration(compilationUnit, "voidSymbol");
4421 EvaluationResultImpl voidSymbolResult = 4325 EvaluationResultImpl voidSymbolResult =
4422 (voidSymbol.element as VariableElementImpl).evaluationResult; 4326 (voidSymbol.element as VariableElementImpl).evaluationResult;
4423 DartObjectImpl value = voidSymbolResult.value; 4327 DartObjectImpl value = voidSymbolResult.value;
4424 JUnitTestCase.assertEquals(typeProvider.symbolType, value.type); 4328 expect(value.type, typeProvider.symbolType);
4425 JUnitTestCase.assertEquals("void", value.value); 4329 expect(value.value, "void");
4426 } 4330 }
4427 4331
4428 Map<String, DartObjectImpl> _assertFieldType(Map<String, 4332 Map<String, DartObjectImpl> _assertFieldType(Map<String,
4429 DartObjectImpl> fields, String fieldName, String expectedType) { 4333 DartObjectImpl> fields, String fieldName, String expectedType) {
4430 DartObjectImpl field = fields[fieldName]; 4334 DartObjectImpl field = fields[fieldName];
4431 JUnitTestCase.assertEquals(expectedType, field.type.displayName); 4335 expect(field.type.displayName, expectedType);
4432 return field.fields; 4336 return field.fields;
4433 } 4337 }
4434 4338
4435 void _assertIntField(Map<String, DartObjectImpl> fields, String fieldName, 4339 void _assertIntField(Map<String, DartObjectImpl> fields, String fieldName,
4436 int expectedValue) { 4340 int expectedValue) {
4437 DartObjectImpl field = fields[fieldName]; 4341 DartObjectImpl field = fields[fieldName];
4438 JUnitTestCase.assertEquals("int", field.type.name); 4342 expect(field.type.name, "int");
4439 JUnitTestCase.assertEquals(expectedValue, field.intValue); 4343 expect(field.intValue, expectedValue);
4440 } 4344 }
4441 4345
4442 void _assertNullField(Map<String, DartObjectImpl> fields, String fieldName) { 4346 void _assertNullField(Map<String, DartObjectImpl> fields, String fieldName) {
4443 DartObjectImpl field = fields[fieldName]; 4347 DartObjectImpl field = fields[fieldName];
4444 JUnitTestCase.assertTrue(field.isNull); 4348 expect(field.isNull, isTrue);
4445 } 4349 }
4446 4350
4447 void _assertProperDependencies(String sourceText, 4351 void _assertProperDependencies(String sourceText,
4448 List<ErrorCode> expectedErrorCodes) { 4352 List<ErrorCode> expectedErrorCodes) {
4449 Source source = addSource(sourceText); 4353 Source source = addSource(sourceText);
4450 LibraryElement element = resolve(source); 4354 LibraryElement element = resolve(source);
4451 CompilationUnit unit = 4355 CompilationUnit unit =
4452 analysisContext.resolveCompilationUnit(source, element); 4356 analysisContext.resolveCompilationUnit(source, element);
4453 JUnitTestCase.assertNotNull(unit); 4357 expect(unit, isNotNull);
4454 ConstantValueComputer computer = _makeConstantValueComputer(); 4358 ConstantValueComputer computer = _makeConstantValueComputer();
4455 computer.add(unit); 4359 computer.add(unit);
4456 computer.computeValues(); 4360 computer.computeValues();
4457 assertErrors(source, expectedErrorCodes); 4361 assertErrors(source, expectedErrorCodes);
4458 } 4362 }
4459 4363
4460 Map<String, DartObjectImpl> _assertType(EvaluationResultImpl result, 4364 Map<String, DartObjectImpl> _assertType(EvaluationResultImpl result,
4461 String typeName) { 4365 String typeName) {
4462 JUnitTestCase.assertNotNull(result.value); 4366 expect(result.value, isNotNull);
4463 DartObjectImpl value = result.value; 4367 DartObjectImpl value = result.value;
4464 JUnitTestCase.assertEquals(typeName, value.type.displayName); 4368 expect(value.type.displayName, typeName);
4465 return value.fields; 4369 return value.fields;
4466 } 4370 }
4467 4371
4468 bool _assertValidBool(EvaluationResultImpl result) { 4372 bool _assertValidBool(EvaluationResultImpl result) {
4469 JUnitTestCase.assertNotNull(result.value); 4373 expect(result.value, isNotNull);
4470 DartObjectImpl value = result.value; 4374 DartObjectImpl value = result.value;
4471 JUnitTestCase.assertEquals(typeProvider.boolType, value.type); 4375 expect(value.type, typeProvider.boolType);
4472 bool boolValue = value.boolValue; 4376 bool boolValue = value.boolValue;
4473 JUnitTestCase.assertNotNull(boolValue); 4377 expect(boolValue, isNotNull);
4474 return boolValue; 4378 return boolValue;
4475 } 4379 }
4476 4380
4477 int _assertValidInt(EvaluationResultImpl result) { 4381 int _assertValidInt(EvaluationResultImpl result) {
4478 JUnitTestCase.assertNotNull(result.value); 4382 expect(result.value, isNotNull);
4479 DartObjectImpl value = result.value; 4383 DartObjectImpl value = result.value;
4480 JUnitTestCase.assertEquals(typeProvider.intType, value.type); 4384 expect(value.type, typeProvider.intType);
4481 return value.intValue; 4385 return value.intValue;
4482 } 4386 }
4483 4387
4484 void _assertValidNull(EvaluationResultImpl result) { 4388 void _assertValidNull(EvaluationResultImpl result) {
4485 JUnitTestCase.assertNotNull(result.value); 4389 expect(result.value, isNotNull);
4486 DartObjectImpl value = result.value; 4390 DartObjectImpl value = result.value;
4487 JUnitTestCase.assertEquals(typeProvider.nullType, value.type); 4391 expect(value.type, typeProvider.nullType);
4488 } 4392 }
4489 4393
4490 String _assertValidString(EvaluationResultImpl result) { 4394 String _assertValidString(EvaluationResultImpl result) {
4491 JUnitTestCase.assertNotNull(result.value); 4395 expect(result.value, isNotNull);
4492 DartObjectImpl value = result.value; 4396 DartObjectImpl value = result.value;
4493 JUnitTestCase.assertEquals(typeProvider.stringType, value.type); 4397 expect(value.type, typeProvider.stringType);
4494 return value.stringValue; 4398 return value.stringValue;
4495 } 4399 }
4496 4400
4497 void _assertValidUnknown(EvaluationResultImpl result) { 4401 void _assertValidUnknown(EvaluationResultImpl result) {
4498 JUnitTestCase.assertNotNull(result.value); 4402 expect(result.value, isNotNull);
4499 DartObjectImpl value = result.value; 4403 DartObjectImpl value = result.value;
4500 JUnitTestCase.assertTrue(value.isUnknown); 4404 expect(value.isUnknown, isTrue);
4501 } 4405 }
4502 4406
4503 void _checkInstanceCreationOptionalParams(bool isFieldFormal, bool isNamed, 4407 void _checkInstanceCreationOptionalParams(bool isFieldFormal, bool isNamed,
4504 bool hasDefault) { 4408 bool hasDefault) {
4505 String fieldName = "j"; 4409 String fieldName = "j";
4506 String paramName = isFieldFormal ? fieldName : "i"; 4410 String paramName = isFieldFormal ? fieldName : "i";
4507 String formalParam = 4411 String formalParam =
4508 "${isFieldFormal ? "this." : "int "}$paramName${hasDefault ? " = 3" : "" }"; 4412 "${isFieldFormal ? "this." : "int "}$paramName${hasDefault ? " = 3" : "" }";
4509 CompilationUnit compilationUnit = resolveSource(""" 4413 CompilationUnit compilationUnit = resolveSource("""
4510 const x = const A(); 4414 const x = const A();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4607 4511
4608 ConstantValueComputer _makeConstantValueComputer() { 4512 ConstantValueComputer _makeConstantValueComputer() {
4609 return new ValidatingConstantValueComputer( 4513 return new ValidatingConstantValueComputer(
4610 analysisContext2.typeProvider, 4514 analysisContext2.typeProvider,
4611 analysisContext2.declaredVariables); 4515 analysisContext2.declaredVariables);
4612 } 4516 }
4613 4517
4614 void _validate(bool shouldBeValid, VariableDeclarationList declarationList) { 4518 void _validate(bool shouldBeValid, VariableDeclarationList declarationList) {
4615 for (VariableDeclaration declaration in declarationList.variables) { 4519 for (VariableDeclaration declaration in declarationList.variables) {
4616 VariableElementImpl element = declaration.element as VariableElementImpl; 4520 VariableElementImpl element = declaration.element as VariableElementImpl;
4617 JUnitTestCase.assertNotNull(element); 4521 expect(element, isNotNull);
4618 EvaluationResultImpl result = element.evaluationResult; 4522 EvaluationResultImpl result = element.evaluationResult;
4619 if (shouldBeValid) { 4523 if (shouldBeValid) {
4620 JUnitTestCase.assertNotNull(result.value); 4524 expect(result.value, isNotNull);
4621 } else { 4525 } else {
4622 JUnitTestCase.assertNull(result.value); 4526 expect(result.value, isNull);
4623 } 4527 }
4624 } 4528 }
4625 } 4529 }
4626 } 4530 }
4627 4531
4628 4532
4629 class ConstantValueComputerTest_ValidatingConstantVisitor extends 4533 class ConstantValueComputerTest_ValidatingConstantVisitor extends
4630 ConstantVisitor { 4534 ConstantVisitor {
4631 final DirectedGraph<AstNode> _referenceGraph; 4535 final DirectedGraph<AstNode> _referenceGraph;
4632 final AstNode _nodeBeingEvaluated; 4536 final AstNode _nodeBeingEvaluated;
4633 4537
4634 ConstantValueComputerTest_ValidatingConstantVisitor(TypeProvider typeProvider, 4538 ConstantValueComputerTest_ValidatingConstantVisitor(TypeProvider typeProvider,
4635 this._referenceGraph, this._nodeBeingEvaluated, ErrorReporter errorReporte r) 4539 this._referenceGraph, this._nodeBeingEvaluated, ErrorReporter errorReporte r)
4636 : super.con1(typeProvider, errorReporter); 4540 : super.con1(typeProvider, errorReporter);
4637 4541
4638 @override 4542 @override
4639 void beforeGetEvaluationResult(AstNode node) { 4543 void beforeGetEvaluationResult(AstNode node) {
4640 super.beforeGetEvaluationResult(node); 4544 super.beforeGetEvaluationResult(node);
4641 // If we are getting the evaluation result for a node in the graph, 4545 // If we are getting the evaluation result for a node in the graph,
4642 // make sure we properly recorded the dependency. 4546 // make sure we properly recorded the dependency.
4643 if (_referenceGraph.nodes.contains(node)) { 4547 if (_referenceGraph.nodes.contains(node)) {
4644 JUnitTestCase.assertTrue( 4548 expect(_referenceGraph.containsPath(_nodeBeingEvaluated, node), isTrue);
4645 _referenceGraph.containsPath(_nodeBeingEvaluated, node));
4646 } 4549 }
4647 } 4550 }
4648 } 4551 }
4649 4552
4650 4553
4651 class ConstantVisitorTest extends ResolverTestCase { 4554 class ConstantVisitorTest extends ResolverTestCase {
4652 void test_visitConditionalExpression_false() { 4555 void test_visitConditionalExpression_false() {
4653 Expression thenExpression = AstFactory.integer(1); 4556 Expression thenExpression = AstFactory.integer(1);
4654 Expression elseExpression = AstFactory.integer(0); 4557 Expression elseExpression = AstFactory.integer(0);
4655 ConditionalExpression expression = AstFactory.conditionalExpression( 4558 ConditionalExpression expression = AstFactory.conditionalExpression(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4702 NullLiteral conditionExpression = AstFactory.nullLiteral(); 4605 NullLiteral conditionExpression = AstFactory.nullLiteral();
4703 ConditionalExpression expression = AstFactory.conditionalExpression( 4606 ConditionalExpression expression = AstFactory.conditionalExpression(
4704 conditionExpression, 4607 conditionExpression,
4705 thenExpression, 4608 thenExpression,
4706 elseExpression); 4609 elseExpression);
4707 GatheringErrorListener errorListener = new GatheringErrorListener(); 4610 GatheringErrorListener errorListener = new GatheringErrorListener();
4708 ErrorReporter errorReporter = 4611 ErrorReporter errorReporter =
4709 new ErrorReporter(errorListener, _dummySource()); 4612 new ErrorReporter(errorListener, _dummySource());
4710 DartObjectImpl result = expression.accept( 4613 DartObjectImpl result = expression.accept(
4711 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); 4614 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter));
4712 JUnitTestCase.assertNull(result); 4615 expect(result, isNull);
4713 errorListener.assertErrorsWithCodes( 4616 errorListener.assertErrorsWithCodes(
4714 [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); 4617 [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
4715 } 4618 }
4716 4619
4717 void test_visitConditionalExpression_nonConstantElse() { 4620 void test_visitConditionalExpression_nonConstantElse() {
4718 Expression thenExpression = AstFactory.integer(1); 4621 Expression thenExpression = AstFactory.integer(1);
4719 Expression elseExpression = AstFactory.identifier3("x"); 4622 Expression elseExpression = AstFactory.identifier3("x");
4720 ConditionalExpression expression = AstFactory.conditionalExpression( 4623 ConditionalExpression expression = AstFactory.conditionalExpression(
4721 AstFactory.booleanLiteral(true), 4624 AstFactory.booleanLiteral(true),
4722 thenExpression, 4625 thenExpression,
4723 elseExpression); 4626 elseExpression);
4724 GatheringErrorListener errorListener = new GatheringErrorListener(); 4627 GatheringErrorListener errorListener = new GatheringErrorListener();
4725 ErrorReporter errorReporter = 4628 ErrorReporter errorReporter =
4726 new ErrorReporter(errorListener, _dummySource()); 4629 new ErrorReporter(errorListener, _dummySource());
4727 DartObjectImpl result = expression.accept( 4630 DartObjectImpl result = expression.accept(
4728 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); 4631 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter));
4729 JUnitTestCase.assertNull(result); 4632 expect(result, isNull);
4730 errorListener.assertErrorsWithCodes( 4633 errorListener.assertErrorsWithCodes(
4731 [CompileTimeErrorCode.INVALID_CONSTANT]); 4634 [CompileTimeErrorCode.INVALID_CONSTANT]);
4732 } 4635 }
4733 4636
4734 void test_visitConditionalExpression_nonConstantThen() { 4637 void test_visitConditionalExpression_nonConstantThen() {
4735 Expression thenExpression = AstFactory.identifier3("x"); 4638 Expression thenExpression = AstFactory.identifier3("x");
4736 Expression elseExpression = AstFactory.integer(0); 4639 Expression elseExpression = AstFactory.integer(0);
4737 ConditionalExpression expression = AstFactory.conditionalExpression( 4640 ConditionalExpression expression = AstFactory.conditionalExpression(
4738 AstFactory.booleanLiteral(true), 4641 AstFactory.booleanLiteral(true),
4739 thenExpression, 4642 thenExpression,
4740 elseExpression); 4643 elseExpression);
4741 GatheringErrorListener errorListener = new GatheringErrorListener(); 4644 GatheringErrorListener errorListener = new GatheringErrorListener();
4742 ErrorReporter errorReporter = 4645 ErrorReporter errorReporter =
4743 new ErrorReporter(errorListener, _dummySource()); 4646 new ErrorReporter(errorListener, _dummySource());
4744 DartObjectImpl result = expression.accept( 4647 DartObjectImpl result = expression.accept(
4745 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); 4648 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter));
4746 JUnitTestCase.assertNull(result); 4649 expect(result, isNull);
4747 errorListener.assertErrorsWithCodes( 4650 errorListener.assertErrorsWithCodes(
4748 [CompileTimeErrorCode.INVALID_CONSTANT]); 4651 [CompileTimeErrorCode.INVALID_CONSTANT]);
4749 } 4652 }
4750 4653
4751 void test_visitConditionalExpression_true() { 4654 void test_visitConditionalExpression_true() {
4752 Expression thenExpression = AstFactory.integer(1); 4655 Expression thenExpression = AstFactory.integer(1);
4753 Expression elseExpression = AstFactory.integer(0); 4656 Expression elseExpression = AstFactory.integer(0);
4754 ConditionalExpression expression = AstFactory.conditionalExpression( 4657 ConditionalExpression expression = AstFactory.conditionalExpression(
4755 AstFactory.booleanLiteral(true), 4658 AstFactory.booleanLiteral(true),
4756 thenExpression, 4659 thenExpression,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4791 4694
4792 void test_visitSimpleIdentifier_withoutEnvironment() { 4695 void test_visitSimpleIdentifier_withoutEnvironment() {
4793 CompilationUnit compilationUnit = 4696 CompilationUnit compilationUnit =
4794 resolveSource(r''' 4697 resolveSource(r'''
4795 const a = b; 4698 const a = b;
4796 const b = 3;'''); 4699 const b = 3;''');
4797 _assertValue(3, _evaluateConstant(compilationUnit, "a", null)); 4700 _assertValue(3, _evaluateConstant(compilationUnit, "a", null));
4798 } 4701 }
4799 4702
4800 void _assertValue(int expectedValue, DartObjectImpl result) { 4703 void _assertValue(int expectedValue, DartObjectImpl result) {
4801 JUnitTestCase.assertNotNull(result); 4704 expect(result, isNotNull);
4802 JUnitTestCase.assertEquals("int", result.type.name); 4705 expect(result.type.name, "int");
4803 JUnitTestCase.assertEquals(expectedValue, result.intValue); 4706 expect(result.intValue, expectedValue);
4804 } 4707 }
4805 4708
4806 NonExistingSource _dummySource() { 4709 NonExistingSource _dummySource() {
4807 return new NonExistingSource("foo.dart", UriKind.FILE_URI); 4710 return new NonExistingSource("foo.dart", UriKind.FILE_URI);
4808 } 4711 }
4809 4712
4810 DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name, 4713 DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name,
4811 Map<String, DartObjectImpl> lexicalEnvironment) { 4714 Map<String, DartObjectImpl> lexicalEnvironment) {
4812 Source source = compilationUnit.element.source; 4715 Source source = compilationUnit.element.source;
4813 Expression expression = 4716 Expression expression =
4814 findTopLevelConstantExpression(compilationUnit, name); 4717 findTopLevelConstantExpression(compilationUnit, name);
4815 GatheringErrorListener errorListener = new GatheringErrorListener(); 4718 GatheringErrorListener errorListener = new GatheringErrorListener();
4816 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 4719 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
4817 DartObjectImpl result = expression.accept( 4720 DartObjectImpl result = expression.accept(
4818 new ConstantVisitor.con2(typeProvider, lexicalEnvironment, errorReporter )); 4721 new ConstantVisitor.con2(typeProvider, lexicalEnvironment, errorReporter ));
4819 errorListener.assertNoErrors(); 4722 errorListener.assertNoErrors();
4820 return result; 4723 return result;
4821 } 4724 }
4822 } 4725 }
4823 4726
4824 4727
4825 class ContentCacheTest extends JUnitTestCase { 4728 class ContentCacheTest {
4826 void test_setContents() { 4729 void test_setContents() {
4827 Source source = new TestSource(); 4730 Source source = new TestSource();
4828 ContentCache cache = new ContentCache(); 4731 ContentCache cache = new ContentCache();
4829 JUnitTestCase.assertNull(cache.getContents(source)); 4732 expect(cache.getContents(source), isNull);
4830 JUnitTestCase.assertNull(cache.getModificationStamp(source)); 4733 expect(cache.getModificationStamp(source), isNull);
4831 String contents = "library lib;"; 4734 String contents = "library lib;";
4832 JUnitTestCase.assertNull(cache.setContents(source, contents)); 4735 expect(cache.setContents(source, contents), isNull);
4833 JUnitTestCase.assertEquals(contents, cache.getContents(source)); 4736 expect(cache.getContents(source), contents);
4834 JUnitTestCase.assertNotNull(cache.getModificationStamp(source)); 4737 expect(cache.getModificationStamp(source), isNotNull);
4835 JUnitTestCase.assertEquals(contents, cache.setContents(source, contents)); 4738 expect(cache.setContents(source, contents), contents);
4836 JUnitTestCase.assertEquals(contents, cache.setContents(source, null)); 4739 expect(cache.setContents(source, null), contents);
4837 JUnitTestCase.assertNull(cache.getContents(source)); 4740 expect(cache.getContents(source), isNull);
4838 JUnitTestCase.assertNull(cache.getModificationStamp(source)); 4741 expect(cache.getModificationStamp(source), isNull);
4839 JUnitTestCase.assertNull(cache.setContents(source, null)); 4742 expect(cache.setContents(source, null), isNull);
4840 } 4743 }
4841 } 4744 }
4842 4745
4843 4746
4844 class DartObjectImplTest extends EngineTestCase { 4747 class DartObjectImplTest extends EngineTestCase {
4845 TypeProvider _typeProvider = new TestTypeProvider(); 4748 TypeProvider _typeProvider = new TestTypeProvider();
4846 4749
4847 void fail_add_knownString_knownString() { 4750 void fail_add_knownString_knownString() {
4848 JUnitTestCase.fail("New constant semantics are not yet enabled"); 4751 fail("New constant semantics are not yet enabled");
4849 _assertAdd(_stringValue("ab"), _stringValue("a"), _stringValue("b")); 4752 _assertAdd(_stringValue("ab"), _stringValue("a"), _stringValue("b"));
4850 } 4753 }
4851 4754
4852 void fail_add_knownString_unknownString() { 4755 void fail_add_knownString_unknownString() {
4853 JUnitTestCase.fail("New constant semantics are not yet enabled"); 4756 fail("New constant semantics are not yet enabled");
4854 _assertAdd(_stringValue(null), _stringValue("a"), _stringValue(null)); 4757 _assertAdd(_stringValue(null), _stringValue("a"), _stringValue(null));
4855 } 4758 }
4856 4759
4857 void fail_add_unknownString_knownString() { 4760 void fail_add_unknownString_knownString() {
4858 JUnitTestCase.fail("New constant semantics are not yet enabled"); 4761 fail("New constant semantics are not yet enabled");
4859 _assertAdd(_stringValue(null), _stringValue(null), _stringValue("b")); 4762 _assertAdd(_stringValue(null), _stringValue(null), _stringValue("b"));
4860 } 4763 }
4861 void fail_add_unknownString_unknownString() { 4764 void fail_add_unknownString_unknownString() {
4862 JUnitTestCase.fail("New constant semantics are not yet enabled"); 4765 fail("New constant semantics are not yet enabled");
4863 _assertAdd(_stringValue(null), _stringValue(null), _stringValue(null)); 4766 _assertAdd(_stringValue(null), _stringValue(null), _stringValue(null));
4864 } 4767 }
4865 4768
4866 void test_add_knownDouble_knownDouble() { 4769 void test_add_knownDouble_knownDouble() {
4867 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _doubleValue(2.0)); 4770 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _doubleValue(2.0));
4868 } 4771 }
4869 4772
4870 void test_add_knownDouble_knownInt() { 4773 void test_add_knownDouble_knownInt() {
4871 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _intValue(2)); 4774 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _intValue(2));
4872 } 4775 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5150 } 5053 }
5151 5054
5152 void test_equalEqual_string_unknown() { 5055 void test_equalEqual_string_unknown() {
5153 _assertEqualEqual( 5056 _assertEqualEqual(
5154 _boolValue(null), 5057 _boolValue(null),
5155 _stringValue(null), 5058 _stringValue(null),
5156 _stringValue("def")); 5059 _stringValue("def"));
5157 } 5060 }
5158 5061
5159 void test_equals_list_false_differentSizes() { 5062 void test_equals_list_false_differentSizes() {
5160 JUnitTestCase.assertFalse( 5063 expect(_listValue([_boolValue(true)]) ==
5161 _listValue([_boolValue(true)]) == 5064 _listValue([_boolValue(true), _boolValue(false)]), isFalse);
5162 _listValue([_boolValue(true), _boolValue(false)]));
5163 } 5065 }
5164 5066
5165 void test_equals_list_false_sameSize() { 5067 void test_equals_list_false_sameSize() {
5166 JUnitTestCase.assertFalse( 5068 expect(_listValue([_boolValue(true)]) == _listValue([_boolValue(false)]), is False);
5167 _listValue([_boolValue(true)]) == _listValue([_boolValue(false)]));
5168 } 5069 }
5169 5070
5170 void test_equals_list_true_empty() { 5071 void test_equals_list_true_empty() {
5171 JUnitTestCase.assertEquals(_listValue([]), _listValue([])); 5072 expect(_listValue([]), _listValue([]));
5172 } 5073 }
5173 5074
5174 void test_equals_list_true_nonEmpty() { 5075 void test_equals_list_true_nonEmpty() {
5175 JUnitTestCase.assertEquals( 5076 expect(_listValue([_boolValue(true)]), _listValue([_boolValue(true)]));
5176 _listValue([_boolValue(true)]),
5177 _listValue([_boolValue(true)]));
5178 } 5077 }
5179 5078
5180 void test_equals_map_true_empty() { 5079 void test_equals_map_true_empty() {
5181 JUnitTestCase.assertEquals(_mapValue([]), _mapValue([])); 5080 expect(_mapValue([]), _mapValue([]));
5182 } 5081 }
5183 5082
5184 void test_equals_symbol_false() { 5083 void test_equals_symbol_false() {
5185 JUnitTestCase.assertFalse(_symbolValue("a") == _symbolValue("b")); 5084 expect(_symbolValue("a") == _symbolValue("b"), isFalse);
5186 } 5085 }
5187 5086
5188 void test_equals_symbol_true() { 5087 void test_equals_symbol_true() {
5189 JUnitTestCase.assertEquals(_symbolValue("a"), _symbolValue("a")); 5088 expect(_symbolValue("a"), _symbolValue("a"));
5190 } 5089 }
5191 5090
5192 void test_getValue_bool_false() { 5091 void test_getValue_bool_false() {
5193 JUnitTestCase.assertEquals(false, _boolValue(false).value); 5092 expect(_boolValue(false).value, false);
5194 } 5093 }
5195 5094
5196 void test_getValue_bool_true() { 5095 void test_getValue_bool_true() {
5197 JUnitTestCase.assertEquals(true, _boolValue(true).value); 5096 expect(_boolValue(true).value, true);
5198 } 5097 }
5199 5098
5200 void test_getValue_bool_unknown() { 5099 void test_getValue_bool_unknown() {
5201 JUnitTestCase.assertNull(_boolValue(null).value); 5100 expect(_boolValue(null).value, isNull);
5202 } 5101 }
5203 5102
5204 void test_getValue_double_known() { 5103 void test_getValue_double_known() {
5205 double value = 2.3; 5104 double value = 2.3;
5206 JUnitTestCase.assertEquals(value, _doubleValue(value).value); 5105 expect(_doubleValue(value).value, value);
5207 } 5106 }
5208 5107
5209 void test_getValue_double_unknown() { 5108 void test_getValue_double_unknown() {
5210 JUnitTestCase.assertNull(_doubleValue(null).value); 5109 expect(_doubleValue(null).value, isNull);
5211 } 5110 }
5212 5111
5213 void test_getValue_int_known() { 5112 void test_getValue_int_known() {
5214 int value = 23; 5113 int value = 23;
5215 JUnitTestCase.assertEquals(value, _intValue(value).value); 5114 expect(_intValue(value).value, value);
5216 } 5115 }
5217 5116
5218 void test_getValue_int_unknown() { 5117 void test_getValue_int_unknown() {
5219 JUnitTestCase.assertNull(_intValue(null).value); 5118 expect(_intValue(null).value, isNull);
5220 } 5119 }
5221 5120
5222 void test_getValue_list_empty() { 5121 void test_getValue_list_empty() {
5223 Object result = _listValue([]).value; 5122 Object result = _listValue([]).value;
5224 _assertInstanceOfObjectArray(result); 5123 _assertInstanceOfObjectArray(result);
5225 List<Object> array = result as List<Object>; 5124 List<Object> array = result as List<Object>;
5226 EngineTestCase.assertLength(0, array); 5125 EngineTestCase.assertLength(0, array);
5227 } 5126 }
5228 5127
5229 void test_getValue_list_valid() { 5128 void test_getValue_list_valid() {
(...skipping 12 matching lines...) Expand all
5242 5141
5243 void test_getValue_map_valid() { 5142 void test_getValue_map_valid() {
5244 Object result = 5143 Object result =
5245 _mapValue([_stringValue("key"), _stringValue("value")]).value; 5144 _mapValue([_stringValue("key"), _stringValue("value")]).value;
5246 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result); 5145 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result);
5247 Map map = result as Map; 5146 Map map = result as Map;
5248 EngineTestCase.assertSizeOfMap(1, map); 5147 EngineTestCase.assertSizeOfMap(1, map);
5249 } 5148 }
5250 5149
5251 void test_getValue_null() { 5150 void test_getValue_null() {
5252 JUnitTestCase.assertNull(_nullValue().value); 5151 expect(_nullValue().value, isNull);
5253 } 5152 }
5254 5153
5255 void test_getValue_string_known() { 5154 void test_getValue_string_known() {
5256 String value = "twenty-three"; 5155 String value = "twenty-three";
5257 JUnitTestCase.assertEquals(value, _stringValue(value).value); 5156 expect(_stringValue(value).value, value);
5258 } 5157 }
5259 5158
5260 void test_getValue_string_unknown() { 5159 void test_getValue_string_unknown() {
5261 JUnitTestCase.assertNull(_stringValue(null).value); 5160 expect(_stringValue(null).value, isNull);
5262 } 5161 }
5263 5162
5264 void test_greaterThanOrEqual_knownDouble_knownDouble_false() { 5163 void test_greaterThanOrEqual_knownDouble_knownDouble_false() {
5265 _assertGreaterThanOrEqual( 5164 _assertGreaterThanOrEqual(
5266 _boolValue(false), 5165 _boolValue(false),
5267 _doubleValue(1.0), 5166 _doubleValue(1.0),
5268 _doubleValue(2.0)); 5167 _doubleValue(2.0));
5269 } 5168 }
5270 5169
5271 void test_greaterThanOrEqual_knownDouble_knownDouble_true() { 5170 void test_greaterThanOrEqual_knownDouble_knownDouble_true() {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
5413 5312
5414 void test_greaterThan_unknownInt_knownDouble() { 5313 void test_greaterThan_unknownInt_knownDouble() {
5415 _assertGreaterThan(_boolValue(null), _intValue(null), _doubleValue(2.0)); 5314 _assertGreaterThan(_boolValue(null), _intValue(null), _doubleValue(2.0));
5416 } 5315 }
5417 5316
5418 void test_greaterThan_unknownInt_knownInt() { 5317 void test_greaterThan_unknownInt_knownInt() {
5419 _assertGreaterThan(_boolValue(null), _intValue(null), _intValue(2)); 5318 _assertGreaterThan(_boolValue(null), _intValue(null), _intValue(2));
5420 } 5319 }
5421 5320
5422 void test_hasExactValue_bool_false() { 5321 void test_hasExactValue_bool_false() {
5423 JUnitTestCase.assertTrue(_boolValue(false).hasExactValue); 5322 expect(_boolValue(false).hasExactValue, isTrue);
5424 } 5323 }
5425 5324
5426 void test_hasExactValue_bool_true() { 5325 void test_hasExactValue_bool_true() {
5427 JUnitTestCase.assertTrue(_boolValue(true).hasExactValue); 5326 expect(_boolValue(true).hasExactValue, isTrue);
5428 } 5327 }
5429 5328
5430 void test_hasExactValue_bool_unknown() { 5329 void test_hasExactValue_bool_unknown() {
5431 JUnitTestCase.assertTrue(_boolValue(null).hasExactValue); 5330 expect(_boolValue(null).hasExactValue, isTrue);
5432 } 5331 }
5433 5332
5434 void test_hasExactValue_double_known() { 5333 void test_hasExactValue_double_known() {
5435 JUnitTestCase.assertTrue(_doubleValue(2.3).hasExactValue); 5334 expect(_doubleValue(2.3).hasExactValue, isTrue);
5436 } 5335 }
5437 5336
5438 void test_hasExactValue_double_unknown() { 5337 void test_hasExactValue_double_unknown() {
5439 JUnitTestCase.assertTrue(_doubleValue(null).hasExactValue); 5338 expect(_doubleValue(null).hasExactValue, isTrue);
5440 } 5339 }
5441 5340
5442 void test_hasExactValue_dynamic() { 5341 void test_hasExactValue_dynamic() {
5443 JUnitTestCase.assertFalse(_dynamicValue().hasExactValue); 5342 expect(_dynamicValue().hasExactValue, isFalse);
5444 } 5343 }
5445 5344
5446 void test_hasExactValue_int_known() { 5345 void test_hasExactValue_int_known() {
5447 JUnitTestCase.assertTrue(_intValue(23).hasExactValue); 5346 expect(_intValue(23).hasExactValue, isTrue);
5448 } 5347 }
5449 5348
5450 void test_hasExactValue_int_unknown() { 5349 void test_hasExactValue_int_unknown() {
5451 JUnitTestCase.assertTrue(_intValue(null).hasExactValue); 5350 expect(_intValue(null).hasExactValue, isTrue);
5452 } 5351 }
5453 5352
5454 void test_hasExactValue_list_empty() { 5353 void test_hasExactValue_list_empty() {
5455 JUnitTestCase.assertTrue(_listValue([]).hasExactValue); 5354 expect(_listValue([]).hasExactValue, isTrue);
5456 } 5355 }
5457 5356
5458 void test_hasExactValue_list_invalid() { 5357 void test_hasExactValue_list_invalid() {
5459 JUnitTestCase.assertFalse(_dynamicValue().hasExactValue); 5358 expect(_dynamicValue().hasExactValue, isFalse);
5460 } 5359 }
5461 5360
5462 void test_hasExactValue_list_valid() { 5361 void test_hasExactValue_list_valid() {
5463 JUnitTestCase.assertTrue(_listValue([_intValue(23)]).hasExactValue); 5362 expect(_listValue([_intValue(23)]).hasExactValue, isTrue);
5464 } 5363 }
5465 5364
5466 void test_hasExactValue_map_empty() { 5365 void test_hasExactValue_map_empty() {
5467 JUnitTestCase.assertTrue(_mapValue([]).hasExactValue); 5366 expect(_mapValue([]).hasExactValue, isTrue);
5468 } 5367 }
5469 5368
5470 void test_hasExactValue_map_invalidKey() { 5369 void test_hasExactValue_map_invalidKey() {
5471 JUnitTestCase.assertFalse( 5370 expect(_mapValue([_dynamicValue(), _stringValue("value")]).hasExactValue, is False);
5472 _mapValue([_dynamicValue(), _stringValue("value")]).hasExactValue);
5473 } 5371 }
5474 5372
5475 void test_hasExactValue_map_invalidValue() { 5373 void test_hasExactValue_map_invalidValue() {
5476 JUnitTestCase.assertFalse( 5374 expect(_mapValue([_stringValue("key"), _dynamicValue()]).hasExactValue, isFa lse);
5477 _mapValue([_stringValue("key"), _dynamicValue()]).hasExactValue);
5478 } 5375 }
5479 5376
5480 void test_hasExactValue_map_valid() { 5377 void test_hasExactValue_map_valid() {
5481 JUnitTestCase.assertTrue( 5378 expect(_mapValue([_stringValue("key"), _stringValue("value")]).hasExactValue , isTrue);
5482 _mapValue([_stringValue("key"), _stringValue("value")]).hasExactValue);
5483 } 5379 }
5484 5380
5485 void test_hasExactValue_null() { 5381 void test_hasExactValue_null() {
5486 JUnitTestCase.assertTrue(_nullValue().hasExactValue); 5382 expect(_nullValue().hasExactValue, isTrue);
5487 } 5383 }
5488 5384
5489 void test_hasExactValue_num() { 5385 void test_hasExactValue_num() {
5490 JUnitTestCase.assertFalse(_numValue().hasExactValue); 5386 expect(_numValue().hasExactValue, isFalse);
5491 } 5387 }
5492 5388
5493 void test_hasExactValue_string_known() { 5389 void test_hasExactValue_string_known() {
5494 JUnitTestCase.assertTrue(_stringValue("twenty-three").hasExactValue); 5390 expect(_stringValue("twenty-three").hasExactValue, isTrue);
5495 } 5391 }
5496 5392
5497 void test_hasExactValue_string_unknown() { 5393 void test_hasExactValue_string_unknown() {
5498 JUnitTestCase.assertTrue(_stringValue(null).hasExactValue); 5394 expect(_stringValue(null).hasExactValue, isTrue);
5499 } 5395 }
5500 5396
5501 void test_integerDivide_knownDouble_knownDouble() { 5397 void test_integerDivide_knownDouble_knownDouble() {
5502 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _doubleValue(2.0)); 5398 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _doubleValue(2.0));
5503 } 5399 }
5504 5400
5505 void test_integerDivide_knownDouble_knownInt() { 5401 void test_integerDivide_knownDouble_knownInt() {
5506 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _intValue(2)); 5402 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _intValue(2));
5507 } 5403 }
5508 5404
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 5446
5551 void test_integerDivide_unknownInt_knownDouble() { 5447 void test_integerDivide_unknownInt_knownDouble() {
5552 _assertIntegerDivide(_intValue(null), _intValue(null), _doubleValue(2.0)); 5448 _assertIntegerDivide(_intValue(null), _intValue(null), _doubleValue(2.0));
5553 } 5449 }
5554 5450
5555 void test_integerDivide_unknownInt_knownInt() { 5451 void test_integerDivide_unknownInt_knownInt() {
5556 _assertIntegerDivide(_intValue(null), _intValue(null), _intValue(2)); 5452 _assertIntegerDivide(_intValue(null), _intValue(null), _intValue(2));
5557 } 5453 }
5558 5454
5559 void test_isBoolNumStringOrNull_bool_false() { 5455 void test_isBoolNumStringOrNull_bool_false() {
5560 JUnitTestCase.assertTrue(_boolValue(false).isBoolNumStringOrNull); 5456 expect(_boolValue(false).isBoolNumStringOrNull, isTrue);
5561 } 5457 }
5562 5458
5563 void test_isBoolNumStringOrNull_bool_true() { 5459 void test_isBoolNumStringOrNull_bool_true() {
5564 JUnitTestCase.assertTrue(_boolValue(true).isBoolNumStringOrNull); 5460 expect(_boolValue(true).isBoolNumStringOrNull, isTrue);
5565 } 5461 }
5566 5462
5567 void test_isBoolNumStringOrNull_bool_unknown() { 5463 void test_isBoolNumStringOrNull_bool_unknown() {
5568 JUnitTestCase.assertTrue(_boolValue(null).isBoolNumStringOrNull); 5464 expect(_boolValue(null).isBoolNumStringOrNull, isTrue);
5569 } 5465 }
5570 5466
5571 void test_isBoolNumStringOrNull_double_known() { 5467 void test_isBoolNumStringOrNull_double_known() {
5572 JUnitTestCase.assertTrue(_doubleValue(2.3).isBoolNumStringOrNull); 5468 expect(_doubleValue(2.3).isBoolNumStringOrNull, isTrue);
5573 } 5469 }
5574 5470
5575 void test_isBoolNumStringOrNull_double_unknown() { 5471 void test_isBoolNumStringOrNull_double_unknown() {
5576 JUnitTestCase.assertTrue(_doubleValue(null).isBoolNumStringOrNull); 5472 expect(_doubleValue(null).isBoolNumStringOrNull, isTrue);
5577 } 5473 }
5578 5474
5579 void test_isBoolNumStringOrNull_dynamic() { 5475 void test_isBoolNumStringOrNull_dynamic() {
5580 JUnitTestCase.assertTrue(_dynamicValue().isBoolNumStringOrNull); 5476 expect(_dynamicValue().isBoolNumStringOrNull, isTrue);
5581 } 5477 }
5582 5478
5583 void test_isBoolNumStringOrNull_int_known() { 5479 void test_isBoolNumStringOrNull_int_known() {
5584 JUnitTestCase.assertTrue(_intValue(23).isBoolNumStringOrNull); 5480 expect(_intValue(23).isBoolNumStringOrNull, isTrue);
5585 } 5481 }
5586 5482
5587 void test_isBoolNumStringOrNull_int_unknown() { 5483 void test_isBoolNumStringOrNull_int_unknown() {
5588 JUnitTestCase.assertTrue(_intValue(null).isBoolNumStringOrNull); 5484 expect(_intValue(null).isBoolNumStringOrNull, isTrue);
5589 } 5485 }
5590 5486
5591 void test_isBoolNumStringOrNull_list() { 5487 void test_isBoolNumStringOrNull_list() {
5592 JUnitTestCase.assertFalse(_listValue([]).isBoolNumStringOrNull); 5488 expect(_listValue([]).isBoolNumStringOrNull, isFalse);
5593 } 5489 }
5594 5490
5595 void test_isBoolNumStringOrNull_null() { 5491 void test_isBoolNumStringOrNull_null() {
5596 JUnitTestCase.assertTrue(_nullValue().isBoolNumStringOrNull); 5492 expect(_nullValue().isBoolNumStringOrNull, isTrue);
5597 } 5493 }
5598 5494
5599 void test_isBoolNumStringOrNull_num() { 5495 void test_isBoolNumStringOrNull_num() {
5600 JUnitTestCase.assertTrue(_numValue().isBoolNumStringOrNull); 5496 expect(_numValue().isBoolNumStringOrNull, isTrue);
5601 } 5497 }
5602 5498
5603 void test_isBoolNumStringOrNull_string_known() { 5499 void test_isBoolNumStringOrNull_string_known() {
5604 JUnitTestCase.assertTrue( 5500 expect(_stringValue("twenty-three").isBoolNumStringOrNull, isTrue);
5605 _stringValue("twenty-three").isBoolNumStringOrNull);
5606 } 5501 }
5607 5502
5608 void test_isBoolNumStringOrNull_string_unknown() { 5503 void test_isBoolNumStringOrNull_string_unknown() {
5609 JUnitTestCase.assertTrue(_stringValue(null).isBoolNumStringOrNull); 5504 expect(_stringValue(null).isBoolNumStringOrNull, isTrue);
5610 } 5505 }
5611 5506
5612 void test_lessThanOrEqual_knownDouble_knownDouble_false() { 5507 void test_lessThanOrEqual_knownDouble_knownDouble_false() {
5613 _assertLessThanOrEqual( 5508 _assertLessThanOrEqual(
5614 _boolValue(false), 5509 _boolValue(false),
5615 _doubleValue(2.0), 5510 _doubleValue(2.0),
5616 _doubleValue(1.0)); 5511 _doubleValue(1.0));
5617 } 5512 }
5618 5513
5619 void test_lessThanOrEqual_knownDouble_knownDouble_true() { 5514 void test_lessThanOrEqual_knownDouble_knownDouble_true() {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
5755 _assertLessThan(_boolValue(null), _intValue(null), _intValue(2)); 5650 _assertLessThan(_boolValue(null), _intValue(null), _intValue(2));
5756 } 5651 }
5757 5652
5758 void test_logicalAnd_false_false() { 5653 void test_logicalAnd_false_false() {
5759 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(false)); 5654 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(false));
5760 } 5655 }
5761 5656
5762 void test_logicalAnd_false_null() { 5657 void test_logicalAnd_false_null() {
5763 try { 5658 try {
5764 _assertLogicalAnd(_boolValue(false), _boolValue(false), _nullValue()); 5659 _assertLogicalAnd(_boolValue(false), _boolValue(false), _nullValue());
5765 JUnitTestCase.fail("Expected EvaluationException"); 5660 fail("Expected EvaluationException");
5766 } on EvaluationException catch (exception) { 5661 } on EvaluationException catch (exception) {
5767 } 5662 }
5768 } 5663 }
5769 5664
5770 void test_logicalAnd_false_string() { 5665 void test_logicalAnd_false_string() {
5771 try { 5666 try {
5772 _assertLogicalAnd( 5667 _assertLogicalAnd(
5773 _boolValue(false), 5668 _boolValue(false),
5774 _boolValue(false), 5669 _boolValue(false),
5775 _stringValue("false")); 5670 _stringValue("false"));
5776 JUnitTestCase.fail("Expected EvaluationException"); 5671 fail("Expected EvaluationException");
5777 } on EvaluationException catch (exception) { 5672 } on EvaluationException catch (exception) {
5778 } 5673 }
5779 } 5674 }
5780 5675
5781 void test_logicalAnd_false_true() { 5676 void test_logicalAnd_false_true() {
5782 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(true)); 5677 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(true));
5783 } 5678 }
5784 5679
5785 void test_logicalAnd_null_false() { 5680 void test_logicalAnd_null_false() {
5786 try { 5681 try {
5787 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(false)); 5682 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(false));
5788 JUnitTestCase.fail("Expected EvaluationException"); 5683 fail("Expected EvaluationException");
5789 } on EvaluationException catch (exception) { 5684 } on EvaluationException catch (exception) {
5790 } 5685 }
5791 } 5686 }
5792 5687
5793 void test_logicalAnd_null_true() { 5688 void test_logicalAnd_null_true() {
5794 try { 5689 try {
5795 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(true)); 5690 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(true));
5796 JUnitTestCase.fail("Expected EvaluationException"); 5691 fail("Expected EvaluationException");
5797 } on EvaluationException catch (exception) { 5692 } on EvaluationException catch (exception) {
5798 } 5693 }
5799 } 5694 }
5800 5695
5801 void test_logicalAnd_string_false() { 5696 void test_logicalAnd_string_false() {
5802 try { 5697 try {
5803 _assertLogicalAnd( 5698 _assertLogicalAnd(
5804 _boolValue(false), 5699 _boolValue(false),
5805 _stringValue("true"), 5700 _stringValue("true"),
5806 _boolValue(false)); 5701 _boolValue(false));
5807 JUnitTestCase.fail("Expected EvaluationException"); 5702 fail("Expected EvaluationException");
5808 } on EvaluationException catch (exception) { 5703 } on EvaluationException catch (exception) {
5809 } 5704 }
5810 } 5705 }
5811 5706
5812 void test_logicalAnd_string_true() { 5707 void test_logicalAnd_string_true() {
5813 try { 5708 try {
5814 _assertLogicalAnd( 5709 _assertLogicalAnd(
5815 _boolValue(false), 5710 _boolValue(false),
5816 _stringValue("false"), 5711 _stringValue("false"),
5817 _boolValue(true)); 5712 _boolValue(true));
5818 JUnitTestCase.fail("Expected EvaluationException"); 5713 fail("Expected EvaluationException");
5819 } on EvaluationException catch (exception) { 5714 } on EvaluationException catch (exception) {
5820 } 5715 }
5821 } 5716 }
5822 5717
5823 void test_logicalAnd_true_false() { 5718 void test_logicalAnd_true_false() {
5824 _assertLogicalAnd(_boolValue(false), _boolValue(true), _boolValue(false)); 5719 _assertLogicalAnd(_boolValue(false), _boolValue(true), _boolValue(false));
5825 } 5720 }
5826 5721
5827 void test_logicalAnd_true_null() { 5722 void test_logicalAnd_true_null() {
5828 _assertLogicalAnd(null, _boolValue(true), _nullValue()); 5723 _assertLogicalAnd(null, _boolValue(true), _nullValue());
5829 } 5724 }
5830 5725
5831 void test_logicalAnd_true_string() { 5726 void test_logicalAnd_true_string() {
5832 try { 5727 try {
5833 _assertLogicalAnd( 5728 _assertLogicalAnd(
5834 _boolValue(false), 5729 _boolValue(false),
5835 _boolValue(true), 5730 _boolValue(true),
5836 _stringValue("true")); 5731 _stringValue("true"));
5837 JUnitTestCase.fail("Expected EvaluationException"); 5732 fail("Expected EvaluationException");
5838 } on EvaluationException catch (exception) { 5733 } on EvaluationException catch (exception) {
5839 } 5734 }
5840 } 5735 }
5841 5736
5842 void test_logicalAnd_true_true() { 5737 void test_logicalAnd_true_true() {
5843 _assertLogicalAnd(_boolValue(true), _boolValue(true), _boolValue(true)); 5738 _assertLogicalAnd(_boolValue(true), _boolValue(true), _boolValue(true));
5844 } 5739 }
5845 5740
5846 void test_logicalNot_false() { 5741 void test_logicalNot_false() {
5847 _assertLogicalNot(_boolValue(true), _boolValue(false)); 5742 _assertLogicalNot(_boolValue(true), _boolValue(false));
5848 } 5743 }
5849 5744
5850 void test_logicalNot_null() { 5745 void test_logicalNot_null() {
5851 _assertLogicalNot(null, _nullValue()); 5746 _assertLogicalNot(null, _nullValue());
5852 } 5747 }
5853 5748
5854 void test_logicalNot_string() { 5749 void test_logicalNot_string() {
5855 try { 5750 try {
5856 _assertLogicalNot(_boolValue(true), _stringValue(null)); 5751 _assertLogicalNot(_boolValue(true), _stringValue(null));
5857 JUnitTestCase.fail("Expected EvaluationException"); 5752 fail("Expected EvaluationException");
5858 } on EvaluationException catch (exception) { 5753 } on EvaluationException catch (exception) {
5859 } 5754 }
5860 } 5755 }
5861 5756
5862 void test_logicalNot_true() { 5757 void test_logicalNot_true() {
5863 _assertLogicalNot(_boolValue(false), _boolValue(true)); 5758 _assertLogicalNot(_boolValue(false), _boolValue(true));
5864 } 5759 }
5865 5760
5866 void test_logicalNot_unknown() { 5761 void test_logicalNot_unknown() {
5867 _assertLogicalNot(_boolValue(null), _boolValue(null)); 5762 _assertLogicalNot(_boolValue(null), _boolValue(null));
5868 } 5763 }
5869 5764
5870 void test_logicalOr_false_false() { 5765 void test_logicalOr_false_false() {
5871 _assertLogicalOr(_boolValue(false), _boolValue(false), _boolValue(false)); 5766 _assertLogicalOr(_boolValue(false), _boolValue(false), _boolValue(false));
5872 } 5767 }
5873 5768
5874 void test_logicalOr_false_null() { 5769 void test_logicalOr_false_null() {
5875 _assertLogicalOr(null, _boolValue(false), _nullValue()); 5770 _assertLogicalOr(null, _boolValue(false), _nullValue());
5876 } 5771 }
5877 5772
5878 void test_logicalOr_false_string() { 5773 void test_logicalOr_false_string() {
5879 try { 5774 try {
5880 _assertLogicalOr( 5775 _assertLogicalOr(
5881 _boolValue(false), 5776 _boolValue(false),
5882 _boolValue(false), 5777 _boolValue(false),
5883 _stringValue("false")); 5778 _stringValue("false"));
5884 JUnitTestCase.fail("Expected EvaluationException"); 5779 fail("Expected EvaluationException");
5885 } on EvaluationException catch (exception) { 5780 } on EvaluationException catch (exception) {
5886 } 5781 }
5887 } 5782 }
5888 5783
5889 void test_logicalOr_false_true() { 5784 void test_logicalOr_false_true() {
5890 _assertLogicalOr(_boolValue(true), _boolValue(false), _boolValue(true)); 5785 _assertLogicalOr(_boolValue(true), _boolValue(false), _boolValue(true));
5891 } 5786 }
5892 5787
5893 void test_logicalOr_null_false() { 5788 void test_logicalOr_null_false() {
5894 try { 5789 try {
5895 _assertLogicalOr(_boolValue(false), _nullValue(), _boolValue(false)); 5790 _assertLogicalOr(_boolValue(false), _nullValue(), _boolValue(false));
5896 JUnitTestCase.fail("Expected EvaluationException"); 5791 fail("Expected EvaluationException");
5897 } on EvaluationException catch (exception) { 5792 } on EvaluationException catch (exception) {
5898 } 5793 }
5899 } 5794 }
5900 5795
5901 void test_logicalOr_null_true() { 5796 void test_logicalOr_null_true() {
5902 try { 5797 try {
5903 _assertLogicalOr(_boolValue(true), _nullValue(), _boolValue(true)); 5798 _assertLogicalOr(_boolValue(true), _nullValue(), _boolValue(true));
5904 JUnitTestCase.fail("Expected EvaluationException"); 5799 fail("Expected EvaluationException");
5905 } on EvaluationException catch (exception) { 5800 } on EvaluationException catch (exception) {
5906 } 5801 }
5907 } 5802 }
5908 5803
5909 void test_logicalOr_string_false() { 5804 void test_logicalOr_string_false() {
5910 try { 5805 try {
5911 _assertLogicalOr( 5806 _assertLogicalOr(
5912 _boolValue(false), 5807 _boolValue(false),
5913 _stringValue("true"), 5808 _stringValue("true"),
5914 _boolValue(false)); 5809 _boolValue(false));
5915 JUnitTestCase.fail("Expected EvaluationException"); 5810 fail("Expected EvaluationException");
5916 } on EvaluationException catch (exception) { 5811 } on EvaluationException catch (exception) {
5917 } 5812 }
5918 } 5813 }
5919 5814
5920 void test_logicalOr_string_true() { 5815 void test_logicalOr_string_true() {
5921 try { 5816 try {
5922 _assertLogicalOr( 5817 _assertLogicalOr(
5923 _boolValue(true), 5818 _boolValue(true),
5924 _stringValue("false"), 5819 _stringValue("false"),
5925 _boolValue(true)); 5820 _boolValue(true));
5926 JUnitTestCase.fail("Expected EvaluationException"); 5821 fail("Expected EvaluationException");
5927 } on EvaluationException catch (exception) { 5822 } on EvaluationException catch (exception) {
5928 } 5823 }
5929 } 5824 }
5930 5825
5931 void test_logicalOr_true_false() { 5826 void test_logicalOr_true_false() {
5932 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(false)); 5827 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(false));
5933 } 5828 }
5934 5829
5935 void test_logicalOr_true_null() { 5830 void test_logicalOr_true_null() {
5936 try { 5831 try {
5937 _assertLogicalOr(_boolValue(true), _boolValue(true), _nullValue()); 5832 _assertLogicalOr(_boolValue(true), _boolValue(true), _nullValue());
5938 JUnitTestCase.fail("Expected EvaluationException"); 5833 fail("Expected EvaluationException");
5939 } on EvaluationException catch (exception) { 5834 } on EvaluationException catch (exception) {
5940 } 5835 }
5941 } 5836 }
5942 5837
5943 void test_logicalOr_true_string() { 5838 void test_logicalOr_true_string() {
5944 try { 5839 try {
5945 _assertLogicalOr( 5840 _assertLogicalOr(
5946 _boolValue(true), 5841 _boolValue(true),
5947 _boolValue(true), 5842 _boolValue(true),
5948 _stringValue("true")); 5843 _stringValue("true"));
5949 JUnitTestCase.fail("Expected EvaluationException"); 5844 fail("Expected EvaluationException");
5950 } on EvaluationException catch (exception) { 5845 } on EvaluationException catch (exception) {
5951 } 5846 }
5952 } 5847 }
5953 5848
5954 void test_logicalOr_true_true() { 5849 void test_logicalOr_true_true() {
5955 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(true)); 5850 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(true));
5956 } 5851 }
5957 5852
5958 void test_minus_knownDouble_knownDouble() { 5853 void test_minus_knownDouble_knownDouble() {
5959 _assertMinus(_doubleValue(1.0), _doubleValue(4.0), _doubleValue(3.0)); 5854 _assertMinus(_doubleValue(1.0), _doubleValue(4.0), _doubleValue(3.0));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
6232 _assertShiftRight(_intValue(null), _intValue(null), _intValue(3)); 6127 _assertShiftRight(_intValue(null), _intValue(null), _intValue(3));
6233 } 6128 }
6234 6129
6235 void test_shiftRight_unknownInt_unknownInt() { 6130 void test_shiftRight_unknownInt_unknownInt() {
6236 _assertShiftRight(_intValue(null), _intValue(null), _intValue(null)); 6131 _assertShiftRight(_intValue(null), _intValue(null), _intValue(null));
6237 } 6132 }
6238 6133
6239 void test_stringLength_int() { 6134 void test_stringLength_int() {
6240 try { 6135 try {
6241 _assertStringLength(_intValue(null), _intValue(0)); 6136 _assertStringLength(_intValue(null), _intValue(0));
6242 JUnitTestCase.fail("Expected EvaluationException"); 6137 fail("Expected EvaluationException");
6243 } on EvaluationException catch (exception) { 6138 } on EvaluationException catch (exception) {
6244 } 6139 }
6245 } 6140 }
6246 6141
6247 void test_stringLength_knownString() { 6142 void test_stringLength_knownString() {
6248 _assertStringLength(_intValue(3), _stringValue("abc")); 6143 _assertStringLength(_intValue(3), _stringValue("abc"));
6249 } 6144 }
6250 6145
6251 void test_stringLength_unknownString() { 6146 void test_stringLength_unknownString() {
6252 _assertStringLength(_intValue(null), _stringValue(null)); 6147 _assertStringLength(_intValue(null), _stringValue(null));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6311 * @param expected the expected result of the operation 6206 * @param expected the expected result of the operation
6312 * @param leftOperand the left operand to the operation 6207 * @param leftOperand the left operand to the operation
6313 * @param rightOperand the left operand to the operation 6208 * @param rightOperand the left operand to the operation
6314 * @throws EvaluationException if the result is an exception when it should no t be 6209 * @throws EvaluationException if the result is an exception when it should no t be
6315 */ 6210 */
6316 void _assertAdd(DartObjectImpl expected, DartObjectImpl leftOperand, 6211 void _assertAdd(DartObjectImpl expected, DartObjectImpl leftOperand,
6317 DartObjectImpl rightOperand) { 6212 DartObjectImpl rightOperand) {
6318 if (expected == null) { 6213 if (expected == null) {
6319 try { 6214 try {
6320 leftOperand.add(_typeProvider, rightOperand); 6215 leftOperand.add(_typeProvider, rightOperand);
6321 JUnitTestCase.fail("Expected an EvaluationException"); 6216 fail("Expected an EvaluationException");
6322 } on EvaluationException catch (exception) { 6217 } on EvaluationException catch (exception) {
6323 } 6218 }
6324 } else { 6219 } else {
6325 DartObjectImpl result = leftOperand.add(_typeProvider, rightOperand); 6220 DartObjectImpl result = leftOperand.add(_typeProvider, rightOperand);
6326 JUnitTestCase.assertNotNull(result); 6221 expect(result, isNotNull);
6327 JUnitTestCase.assertEquals(expected, result); 6222 expect(result, expected);
6328 } 6223 }
6329 } 6224 }
6330 6225
6331 /** 6226 /**
6332 * Assert that the result of bit-anding the left and right operands is the exp ected value, or that 6227 * Assert that the result of bit-anding the left and right operands is the exp ected value, or that
6333 * the operation throws an exception if the expected value is `null`. 6228 * the operation throws an exception if the expected value is `null`.
6334 * 6229 *
6335 * @param expected the expected result of the operation 6230 * @param expected the expected result of the operation
6336 * @param leftOperand the left operand to the operation 6231 * @param leftOperand the left operand to the operation
6337 * @param rightOperand the left operand to the operation 6232 * @param rightOperand the left operand to the operation
6338 * @throws EvaluationException if the result is an exception when it should no t be 6233 * @throws EvaluationException if the result is an exception when it should no t be
6339 */ 6234 */
6340 void _assertBitAnd(DartObjectImpl expected, DartObjectImpl leftOperand, 6235 void _assertBitAnd(DartObjectImpl expected, DartObjectImpl leftOperand,
6341 DartObjectImpl rightOperand) { 6236 DartObjectImpl rightOperand) {
6342 if (expected == null) { 6237 if (expected == null) {
6343 try { 6238 try {
6344 leftOperand.bitAnd(_typeProvider, rightOperand); 6239 leftOperand.bitAnd(_typeProvider, rightOperand);
6345 JUnitTestCase.fail("Expected an EvaluationException"); 6240 fail("Expected an EvaluationException");
6346 } on EvaluationException catch (exception) { 6241 } on EvaluationException catch (exception) {
6347 } 6242 }
6348 } else { 6243 } else {
6349 DartObjectImpl result = leftOperand.bitAnd(_typeProvider, rightOperand); 6244 DartObjectImpl result = leftOperand.bitAnd(_typeProvider, rightOperand);
6350 JUnitTestCase.assertNotNull(result); 6245 expect(result, isNotNull);
6351 JUnitTestCase.assertEquals(expected, result); 6246 expect(result, expected);
6352 } 6247 }
6353 } 6248 }
6354 6249
6355 /** 6250 /**
6356 * Assert that the bit-not of the operand is the expected value, or that the o peration throws an 6251 * Assert that the bit-not of the operand is the expected value, or that the o peration throws an
6357 * exception if the expected value is `null`. 6252 * exception if the expected value is `null`.
6358 * 6253 *
6359 * @param expected the expected result of the operation 6254 * @param expected the expected result of the operation
6360 * @param operand the operand to the operation 6255 * @param operand the operand to the operation
6361 * @throws EvaluationException if the result is an exception when it should no t be 6256 * @throws EvaluationException if the result is an exception when it should no t be
6362 */ 6257 */
6363 void _assertBitNot(DartObjectImpl expected, DartObjectImpl operand) { 6258 void _assertBitNot(DartObjectImpl expected, DartObjectImpl operand) {
6364 if (expected == null) { 6259 if (expected == null) {
6365 try { 6260 try {
6366 operand.bitNot(_typeProvider); 6261 operand.bitNot(_typeProvider);
6367 JUnitTestCase.fail("Expected an EvaluationException"); 6262 fail("Expected an EvaluationException");
6368 } on EvaluationException catch (exception) { 6263 } on EvaluationException catch (exception) {
6369 } 6264 }
6370 } else { 6265 } else {
6371 DartObjectImpl result = operand.bitNot(_typeProvider); 6266 DartObjectImpl result = operand.bitNot(_typeProvider);
6372 JUnitTestCase.assertNotNull(result); 6267 expect(result, isNotNull);
6373 JUnitTestCase.assertEquals(expected, result); 6268 expect(result, expected);
6374 } 6269 }
6375 } 6270 }
6376 6271
6377 /** 6272 /**
6378 * Assert that the result of bit-oring the left and right operands is the expe cted value, or that 6273 * Assert that the result of bit-oring the left and right operands is the expe cted value, or that
6379 * the operation throws an exception if the expected value is `null`. 6274 * the operation throws an exception if the expected value is `null`.
6380 * 6275 *
6381 * @param expected the expected result of the operation 6276 * @param expected the expected result of the operation
6382 * @param leftOperand the left operand to the operation 6277 * @param leftOperand the left operand to the operation
6383 * @param rightOperand the left operand to the operation 6278 * @param rightOperand the left operand to the operation
6384 * @throws EvaluationException if the result is an exception when it should no t be 6279 * @throws EvaluationException if the result is an exception when it should no t be
6385 */ 6280 */
6386 void _assertBitOr(DartObjectImpl expected, DartObjectImpl leftOperand, 6281 void _assertBitOr(DartObjectImpl expected, DartObjectImpl leftOperand,
6387 DartObjectImpl rightOperand) { 6282 DartObjectImpl rightOperand) {
6388 if (expected == null) { 6283 if (expected == null) {
6389 try { 6284 try {
6390 leftOperand.bitOr(_typeProvider, rightOperand); 6285 leftOperand.bitOr(_typeProvider, rightOperand);
6391 JUnitTestCase.fail("Expected an EvaluationException"); 6286 fail("Expected an EvaluationException");
6392 } on EvaluationException catch (exception) { 6287 } on EvaluationException catch (exception) {
6393 } 6288 }
6394 } else { 6289 } else {
6395 DartObjectImpl result = leftOperand.bitOr(_typeProvider, rightOperand); 6290 DartObjectImpl result = leftOperand.bitOr(_typeProvider, rightOperand);
6396 JUnitTestCase.assertNotNull(result); 6291 expect(result, isNotNull);
6397 JUnitTestCase.assertEquals(expected, result); 6292 expect(result, expected);
6398 } 6293 }
6399 } 6294 }
6400 6295
6401 /** 6296 /**
6402 * Assert that the result of bit-xoring the left and right operands is the exp ected value, or that 6297 * Assert that the result of bit-xoring the left and right operands is the exp ected value, or that
6403 * the operation throws an exception if the expected value is `null`. 6298 * the operation throws an exception if the expected value is `null`.
6404 * 6299 *
6405 * @param expected the expected result of the operation 6300 * @param expected the expected result of the operation
6406 * @param leftOperand the left operand to the operation 6301 * @param leftOperand the left operand to the operation
6407 * @param rightOperand the left operand to the operation 6302 * @param rightOperand the left operand to the operation
6408 * @throws EvaluationException if the result is an exception when it should no t be 6303 * @throws EvaluationException if the result is an exception when it should no t be
6409 */ 6304 */
6410 void _assertBitXor(DartObjectImpl expected, DartObjectImpl leftOperand, 6305 void _assertBitXor(DartObjectImpl expected, DartObjectImpl leftOperand,
6411 DartObjectImpl rightOperand) { 6306 DartObjectImpl rightOperand) {
6412 if (expected == null) { 6307 if (expected == null) {
6413 try { 6308 try {
6414 leftOperand.bitXor(_typeProvider, rightOperand); 6309 leftOperand.bitXor(_typeProvider, rightOperand);
6415 JUnitTestCase.fail("Expected an EvaluationException"); 6310 fail("Expected an EvaluationException");
6416 } on EvaluationException catch (exception) { 6311 } on EvaluationException catch (exception) {
6417 } 6312 }
6418 } else { 6313 } else {
6419 DartObjectImpl result = leftOperand.bitXor(_typeProvider, rightOperand); 6314 DartObjectImpl result = leftOperand.bitXor(_typeProvider, rightOperand);
6420 JUnitTestCase.assertNotNull(result); 6315 expect(result, isNotNull);
6421 JUnitTestCase.assertEquals(expected, result); 6316 expect(result, expected);
6422 } 6317 }
6423 } 6318 }
6424 6319
6425 /** 6320 /**
6426 * Assert that the result of concatenating the left and right operands is the expected value, or 6321 * Assert that the result of concatenating the left and right operands is the expected value, or
6427 * that the operation throws an exception if the expected value is `null`. 6322 * that the operation throws an exception if the expected value is `null`.
6428 * 6323 *
6429 * @param expected the expected result of the operation 6324 * @param expected the expected result of the operation
6430 * @param leftOperand the left operand to the operation 6325 * @param leftOperand the left operand to the operation
6431 * @param rightOperand the left operand to the operation 6326 * @param rightOperand the left operand to the operation
6432 * @throws EvaluationException if the result is an exception when it should no t be 6327 * @throws EvaluationException if the result is an exception when it should no t be
6433 */ 6328 */
6434 void _assertConcatenate(DartObjectImpl expected, DartObjectImpl leftOperand, 6329 void _assertConcatenate(DartObjectImpl expected, DartObjectImpl leftOperand,
6435 DartObjectImpl rightOperand) { 6330 DartObjectImpl rightOperand) {
6436 if (expected == null) { 6331 if (expected == null) {
6437 try { 6332 try {
6438 leftOperand.concatenate(_typeProvider, rightOperand); 6333 leftOperand.concatenate(_typeProvider, rightOperand);
6439 JUnitTestCase.fail("Expected an EvaluationException"); 6334 fail("Expected an EvaluationException");
6440 } on EvaluationException catch (exception) { 6335 } on EvaluationException catch (exception) {
6441 } 6336 }
6442 } else { 6337 } else {
6443 DartObjectImpl result = 6338 DartObjectImpl result =
6444 leftOperand.concatenate(_typeProvider, rightOperand); 6339 leftOperand.concatenate(_typeProvider, rightOperand);
6445 JUnitTestCase.assertNotNull(result); 6340 expect(result, isNotNull);
6446 JUnitTestCase.assertEquals(expected, result); 6341 expect(result, expected);
6447 } 6342 }
6448 } 6343 }
6449 6344
6450 /** 6345 /**
6451 * Assert that the result of dividing the left and right operands is the expec ted value, or that 6346 * Assert that the result of dividing the left and right operands is the expec ted value, or that
6452 * the operation throws an exception if the expected value is `null`. 6347 * the operation throws an exception if the expected value is `null`.
6453 * 6348 *
6454 * @param expected the expected result of the operation 6349 * @param expected the expected result of the operation
6455 * @param leftOperand the left operand to the operation 6350 * @param leftOperand the left operand to the operation
6456 * @param rightOperand the left operand to the operation 6351 * @param rightOperand the left operand to the operation
6457 * @throws EvaluationException if the result is an exception when it should no t be 6352 * @throws EvaluationException if the result is an exception when it should no t be
6458 */ 6353 */
6459 void _assertDivide(DartObjectImpl expected, DartObjectImpl leftOperand, 6354 void _assertDivide(DartObjectImpl expected, DartObjectImpl leftOperand,
6460 DartObjectImpl rightOperand) { 6355 DartObjectImpl rightOperand) {
6461 if (expected == null) { 6356 if (expected == null) {
6462 try { 6357 try {
6463 leftOperand.divide(_typeProvider, rightOperand); 6358 leftOperand.divide(_typeProvider, rightOperand);
6464 JUnitTestCase.fail("Expected an EvaluationException"); 6359 fail("Expected an EvaluationException");
6465 } on EvaluationException catch (exception) { 6360 } on EvaluationException catch (exception) {
6466 } 6361 }
6467 } else { 6362 } else {
6468 DartObjectImpl result = leftOperand.divide(_typeProvider, rightOperand); 6363 DartObjectImpl result = leftOperand.divide(_typeProvider, rightOperand);
6469 JUnitTestCase.assertNotNull(result); 6364 expect(result, isNotNull);
6470 JUnitTestCase.assertEquals(expected, result); 6365 expect(result, expected);
6471 } 6366 }
6472 } 6367 }
6473 6368
6474 /** 6369 /**
6475 * Assert that the result of comparing the left and right operands for equalit y is the expected 6370 * Assert that the result of comparing the left and right operands for equalit y is the expected
6476 * value, or that the operation throws an exception if the expected value is ` null`. 6371 * value, or that the operation throws an exception if the expected value is ` null`.
6477 * 6372 *
6478 * @param expected the expected result of the operation 6373 * @param expected the expected result of the operation
6479 * @param leftOperand the left operand to the operation 6374 * @param leftOperand the left operand to the operation
6480 * @param rightOperand the left operand to the operation 6375 * @param rightOperand the left operand to the operation
6481 * @throws EvaluationException if the result is an exception when it should no t be 6376 * @throws EvaluationException if the result is an exception when it should no t be
6482 */ 6377 */
6483 void _assertEqualEqual(DartObjectImpl expected, DartObjectImpl leftOperand, 6378 void _assertEqualEqual(DartObjectImpl expected, DartObjectImpl leftOperand,
6484 DartObjectImpl rightOperand) { 6379 DartObjectImpl rightOperand) {
6485 if (expected == null) { 6380 if (expected == null) {
6486 try { 6381 try {
6487 leftOperand.equalEqual(_typeProvider, rightOperand); 6382 leftOperand.equalEqual(_typeProvider, rightOperand);
6488 JUnitTestCase.fail("Expected an EvaluationException"); 6383 fail("Expected an EvaluationException");
6489 } on EvaluationException catch (exception) { 6384 } on EvaluationException catch (exception) {
6490 } 6385 }
6491 } else { 6386 } else {
6492 DartObjectImpl result = 6387 DartObjectImpl result =
6493 leftOperand.equalEqual(_typeProvider, rightOperand); 6388 leftOperand.equalEqual(_typeProvider, rightOperand);
6494 JUnitTestCase.assertNotNull(result); 6389 expect(result, isNotNull);
6495 JUnitTestCase.assertEquals(expected, result); 6390 expect(result, expected);
6496 } 6391 }
6497 } 6392 }
6498 6393
6499 /** 6394 /**
6500 * Assert that the result of comparing the left and right operands is the expe cted value, or that 6395 * Assert that the result of comparing the left and right operands is the expe cted value, or that
6501 * the operation throws an exception if the expected value is `null`. 6396 * the operation throws an exception if the expected value is `null`.
6502 * 6397 *
6503 * @param expected the expected result of the operation 6398 * @param expected the expected result of the operation
6504 * @param leftOperand the left operand to the operation 6399 * @param leftOperand the left operand to the operation
6505 * @param rightOperand the left operand to the operation 6400 * @param rightOperand the left operand to the operation
6506 * @throws EvaluationException if the result is an exception when it should no t be 6401 * @throws EvaluationException if the result is an exception when it should no t be
6507 */ 6402 */
6508 void _assertGreaterThan(DartObjectImpl expected, DartObjectImpl leftOperand, 6403 void _assertGreaterThan(DartObjectImpl expected, DartObjectImpl leftOperand,
6509 DartObjectImpl rightOperand) { 6404 DartObjectImpl rightOperand) {
6510 if (expected == null) { 6405 if (expected == null) {
6511 try { 6406 try {
6512 leftOperand.greaterThan(_typeProvider, rightOperand); 6407 leftOperand.greaterThan(_typeProvider, rightOperand);
6513 JUnitTestCase.fail("Expected an EvaluationException"); 6408 fail("Expected an EvaluationException");
6514 } on EvaluationException catch (exception) { 6409 } on EvaluationException catch (exception) {
6515 } 6410 }
6516 } else { 6411 } else {
6517 DartObjectImpl result = 6412 DartObjectImpl result =
6518 leftOperand.greaterThan(_typeProvider, rightOperand); 6413 leftOperand.greaterThan(_typeProvider, rightOperand);
6519 JUnitTestCase.assertNotNull(result); 6414 expect(result, isNotNull);
6520 JUnitTestCase.assertEquals(expected, result); 6415 expect(result, expected);
6521 } 6416 }
6522 } 6417 }
6523 6418
6524 /** 6419 /**
6525 * Assert that the result of comparing the left and right operands is the expe cted value, or that 6420 * Assert that the result of comparing the left and right operands is the expe cted value, or that
6526 * the operation throws an exception if the expected value is `null`. 6421 * the operation throws an exception if the expected value is `null`.
6527 * 6422 *
6528 * @param expected the expected result of the operation 6423 * @param expected the expected result of the operation
6529 * @param leftOperand the left operand to the operation 6424 * @param leftOperand the left operand to the operation
6530 * @param rightOperand the left operand to the operation 6425 * @param rightOperand the left operand to the operation
6531 * @throws EvaluationException if the result is an exception when it should no t be 6426 * @throws EvaluationException if the result is an exception when it should no t be
6532 */ 6427 */
6533 void _assertGreaterThanOrEqual(DartObjectImpl expected, 6428 void _assertGreaterThanOrEqual(DartObjectImpl expected,
6534 DartObjectImpl leftOperand, DartObjectImpl rightOperand) { 6429 DartObjectImpl leftOperand, DartObjectImpl rightOperand) {
6535 if (expected == null) { 6430 if (expected == null) {
6536 try { 6431 try {
6537 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand); 6432 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand);
6538 JUnitTestCase.fail("Expected an EvaluationException"); 6433 fail("Expected an EvaluationException");
6539 } on EvaluationException catch (exception) { 6434 } on EvaluationException catch (exception) {
6540 } 6435 }
6541 } else { 6436 } else {
6542 DartObjectImpl result = 6437 DartObjectImpl result =
6543 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand); 6438 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand);
6544 JUnitTestCase.assertNotNull(result); 6439 expect(result, isNotNull);
6545 JUnitTestCase.assertEquals(expected, result); 6440 expect(result, expected);
6546 } 6441 }
6547 } 6442 }
6548 6443
6549 void _assertInstanceOfObjectArray(Object result) { 6444 void _assertInstanceOfObjectArray(Object result) {
6550 // TODO(scheglov) implement 6445 // TODO(scheglov) implement
6551 } 6446 }
6552 6447
6553 /** 6448 /**
6554 * Assert that the result of dividing the left and right operands as integers is the expected 6449 * Assert that the result of dividing the left and right operands as integers is the expected
6555 * value, or that the operation throws an exception if the expected value is ` null`. 6450 * value, or that the operation throws an exception if the expected value is ` null`.
6556 * 6451 *
6557 * @param expected the expected result of the operation 6452 * @param expected the expected result of the operation
6558 * @param leftOperand the left operand to the operation 6453 * @param leftOperand the left operand to the operation
6559 * @param rightOperand the left operand to the operation 6454 * @param rightOperand the left operand to the operation
6560 * @throws EvaluationException if the result is an exception when it should no t be 6455 * @throws EvaluationException if the result is an exception when it should no t be
6561 */ 6456 */
6562 void _assertIntegerDivide(DartObjectImpl expected, DartObjectImpl leftOperand, 6457 void _assertIntegerDivide(DartObjectImpl expected, DartObjectImpl leftOperand,
6563 DartObjectImpl rightOperand) { 6458 DartObjectImpl rightOperand) {
6564 if (expected == null) { 6459 if (expected == null) {
6565 try { 6460 try {
6566 leftOperand.integerDivide(_typeProvider, rightOperand); 6461 leftOperand.integerDivide(_typeProvider, rightOperand);
6567 JUnitTestCase.fail("Expected an EvaluationException"); 6462 fail("Expected an EvaluationException");
6568 } on EvaluationException catch (exception) { 6463 } on EvaluationException catch (exception) {
6569 } 6464 }
6570 } else { 6465 } else {
6571 DartObjectImpl result = 6466 DartObjectImpl result =
6572 leftOperand.integerDivide(_typeProvider, rightOperand); 6467 leftOperand.integerDivide(_typeProvider, rightOperand);
6573 JUnitTestCase.assertNotNull(result); 6468 expect(result, isNotNull);
6574 JUnitTestCase.assertEquals(expected, result); 6469 expect(result, expected);
6575 } 6470 }
6576 } 6471 }
6577 6472
6578 /** 6473 /**
6579 * Assert that the result of comparing the left and right operands is the expe cted value, or that 6474 * Assert that the result of comparing the left and right operands is the expe cted value, or that
6580 * the operation throws an exception if the expected value is `null`. 6475 * the operation throws an exception if the expected value is `null`.
6581 * 6476 *
6582 * @param expected the expected result of the operation 6477 * @param expected the expected result of the operation
6583 * @param leftOperand the left operand to the operation 6478 * @param leftOperand the left operand to the operation
6584 * @param rightOperand the left operand to the operation 6479 * @param rightOperand the left operand to the operation
6585 * @throws EvaluationException if the result is an exception when it should no t be 6480 * @throws EvaluationException if the result is an exception when it should no t be
6586 */ 6481 */
6587 void _assertLessThan(DartObjectImpl expected, DartObjectImpl leftOperand, 6482 void _assertLessThan(DartObjectImpl expected, DartObjectImpl leftOperand,
6588 DartObjectImpl rightOperand) { 6483 DartObjectImpl rightOperand) {
6589 if (expected == null) { 6484 if (expected == null) {
6590 try { 6485 try {
6591 leftOperand.lessThan(_typeProvider, rightOperand); 6486 leftOperand.lessThan(_typeProvider, rightOperand);
6592 JUnitTestCase.fail("Expected an EvaluationException"); 6487 fail("Expected an EvaluationException");
6593 } on EvaluationException catch (exception) { 6488 } on EvaluationException catch (exception) {
6594 } 6489 }
6595 } else { 6490 } else {
6596 DartObjectImpl result = leftOperand.lessThan(_typeProvider, rightOperand); 6491 DartObjectImpl result = leftOperand.lessThan(_typeProvider, rightOperand);
6597 JUnitTestCase.assertNotNull(result); 6492 expect(result, isNotNull);
6598 JUnitTestCase.assertEquals(expected, result); 6493 expect(result, expected);
6599 } 6494 }
6600 } 6495 }
6601 6496
6602 /** 6497 /**
6603 * Assert that the result of comparing the left and right operands is the expe cted value, or that 6498 * Assert that the result of comparing the left and right operands is the expe cted value, or that
6604 * the operation throws an exception if the expected value is `null`. 6499 * the operation throws an exception if the expected value is `null`.
6605 * 6500 *
6606 * @param expected the expected result of the operation 6501 * @param expected the expected result of the operation
6607 * @param leftOperand the left operand to the operation 6502 * @param leftOperand the left operand to the operation
6608 * @param rightOperand the left operand to the operation 6503 * @param rightOperand the left operand to the operation
6609 * @throws EvaluationException if the result is an exception when it should no t be 6504 * @throws EvaluationException if the result is an exception when it should no t be
6610 */ 6505 */
6611 void _assertLessThanOrEqual(DartObjectImpl expected, 6506 void _assertLessThanOrEqual(DartObjectImpl expected,
6612 DartObjectImpl leftOperand, DartObjectImpl rightOperand) { 6507 DartObjectImpl leftOperand, DartObjectImpl rightOperand) {
6613 if (expected == null) { 6508 if (expected == null) {
6614 try { 6509 try {
6615 leftOperand.lessThanOrEqual(_typeProvider, rightOperand); 6510 leftOperand.lessThanOrEqual(_typeProvider, rightOperand);
6616 JUnitTestCase.fail("Expected an EvaluationException"); 6511 fail("Expected an EvaluationException");
6617 } on EvaluationException catch (exception) { 6512 } on EvaluationException catch (exception) {
6618 } 6513 }
6619 } else { 6514 } else {
6620 DartObjectImpl result = 6515 DartObjectImpl result =
6621 leftOperand.lessThanOrEqual(_typeProvider, rightOperand); 6516 leftOperand.lessThanOrEqual(_typeProvider, rightOperand);
6622 JUnitTestCase.assertNotNull(result); 6517 expect(result, isNotNull);
6623 JUnitTestCase.assertEquals(expected, result); 6518 expect(result, expected);
6624 } 6519 }
6625 } 6520 }
6626 6521
6627 /** 6522 /**
6628 * Assert that the result of logical-anding the left and right operands is the expected value, or 6523 * Assert that the result of logical-anding the left and right operands is the expected value, or
6629 * that the operation throws an exception if the expected value is `null`. 6524 * that the operation throws an exception if the expected value is `null`.
6630 * 6525 *
6631 * @param expected the expected result of the operation 6526 * @param expected the expected result of the operation
6632 * @param leftOperand the left operand to the operation 6527 * @param leftOperand the left operand to the operation
6633 * @param rightOperand the left operand to the operation 6528 * @param rightOperand the left operand to the operation
6634 * @throws EvaluationException if the result is an exception when it should no t be 6529 * @throws EvaluationException if the result is an exception when it should no t be
6635 */ 6530 */
6636 void _assertLogicalAnd(DartObjectImpl expected, DartObjectImpl leftOperand, 6531 void _assertLogicalAnd(DartObjectImpl expected, DartObjectImpl leftOperand,
6637 DartObjectImpl rightOperand) { 6532 DartObjectImpl rightOperand) {
6638 if (expected == null) { 6533 if (expected == null) {
6639 try { 6534 try {
6640 leftOperand.logicalAnd(_typeProvider, rightOperand); 6535 leftOperand.logicalAnd(_typeProvider, rightOperand);
6641 JUnitTestCase.fail("Expected an EvaluationException"); 6536 fail("Expected an EvaluationException");
6642 } on EvaluationException catch (exception) { 6537 } on EvaluationException catch (exception) {
6643 } 6538 }
6644 } else { 6539 } else {
6645 DartObjectImpl result = 6540 DartObjectImpl result =
6646 leftOperand.logicalAnd(_typeProvider, rightOperand); 6541 leftOperand.logicalAnd(_typeProvider, rightOperand);
6647 JUnitTestCase.assertNotNull(result); 6542 expect(result, isNotNull);
6648 JUnitTestCase.assertEquals(expected, result); 6543 expect(result, expected);
6649 } 6544 }
6650 } 6545 }
6651 6546
6652 /** 6547 /**
6653 * Assert that the logical-not of the operand is the expected value, or that t he operation throws 6548 * Assert that the logical-not of the operand is the expected value, or that t he operation throws
6654 * an exception if the expected value is `null`. 6549 * an exception if the expected value is `null`.
6655 * 6550 *
6656 * @param expected the expected result of the operation 6551 * @param expected the expected result of the operation
6657 * @param operand the operand to the operation 6552 * @param operand the operand to the operation
6658 * @throws EvaluationException if the result is an exception when it should no t be 6553 * @throws EvaluationException if the result is an exception when it should no t be
6659 */ 6554 */
6660 void _assertLogicalNot(DartObjectImpl expected, DartObjectImpl operand) { 6555 void _assertLogicalNot(DartObjectImpl expected, DartObjectImpl operand) {
6661 if (expected == null) { 6556 if (expected == null) {
6662 try { 6557 try {
6663 operand.logicalNot(_typeProvider); 6558 operand.logicalNot(_typeProvider);
6664 JUnitTestCase.fail("Expected an EvaluationException"); 6559 fail("Expected an EvaluationException");
6665 } on EvaluationException catch (exception) { 6560 } on EvaluationException catch (exception) {
6666 } 6561 }
6667 } else { 6562 } else {
6668 DartObjectImpl result = operand.logicalNot(_typeProvider); 6563 DartObjectImpl result = operand.logicalNot(_typeProvider);
6669 JUnitTestCase.assertNotNull(result); 6564 expect(result, isNotNull);
6670 JUnitTestCase.assertEquals(expected, result); 6565 expect(result, expected);
6671 } 6566 }
6672 } 6567 }
6673 6568
6674 /** 6569 /**
6675 * Assert that the result of logical-oring the left and right operands is the expected value, or 6570 * Assert that the result of logical-oring the left and right operands is the expected value, or
6676 * that the operation throws an exception if the expected value is `null`. 6571 * that the operation throws an exception if the expected value is `null`.
6677 * 6572 *
6678 * @param expected the expected result of the operation 6573 * @param expected the expected result of the operation
6679 * @param leftOperand the left operand to the operation 6574 * @param leftOperand the left operand to the operation
6680 * @param rightOperand the left operand to the operation 6575 * @param rightOperand the left operand to the operation
6681 * @throws EvaluationException if the result is an exception when it should no t be 6576 * @throws EvaluationException if the result is an exception when it should no t be
6682 */ 6577 */
6683 void _assertLogicalOr(DartObjectImpl expected, DartObjectImpl leftOperand, 6578 void _assertLogicalOr(DartObjectImpl expected, DartObjectImpl leftOperand,
6684 DartObjectImpl rightOperand) { 6579 DartObjectImpl rightOperand) {
6685 if (expected == null) { 6580 if (expected == null) {
6686 try { 6581 try {
6687 leftOperand.logicalOr(_typeProvider, rightOperand); 6582 leftOperand.logicalOr(_typeProvider, rightOperand);
6688 JUnitTestCase.fail("Expected an EvaluationException"); 6583 fail("Expected an EvaluationException");
6689 } on EvaluationException catch (exception) { 6584 } on EvaluationException catch (exception) {
6690 } 6585 }
6691 } else { 6586 } else {
6692 DartObjectImpl result = 6587 DartObjectImpl result =
6693 leftOperand.logicalOr(_typeProvider, rightOperand); 6588 leftOperand.logicalOr(_typeProvider, rightOperand);
6694 JUnitTestCase.assertNotNull(result); 6589 expect(result, isNotNull);
6695 JUnitTestCase.assertEquals(expected, result); 6590 expect(result, expected);
6696 } 6591 }
6697 } 6592 }
6698 6593
6699 /** 6594 /**
6700 * Assert that the result of subtracting the left and right operands is the ex pected value, or 6595 * Assert that the result of subtracting the left and right operands is the ex pected value, or
6701 * that the operation throws an exception if the expected value is `null`. 6596 * that the operation throws an exception if the expected value is `null`.
6702 * 6597 *
6703 * @param expected the expected result of the operation 6598 * @param expected the expected result of the operation
6704 * @param leftOperand the left operand to the operation 6599 * @param leftOperand the left operand to the operation
6705 * @param rightOperand the left operand to the operation 6600 * @param rightOperand the left operand to the operation
6706 * @throws EvaluationException if the result is an exception when it should no t be 6601 * @throws EvaluationException if the result is an exception when it should no t be
6707 */ 6602 */
6708 void _assertMinus(DartObjectImpl expected, DartObjectImpl leftOperand, 6603 void _assertMinus(DartObjectImpl expected, DartObjectImpl leftOperand,
6709 DartObjectImpl rightOperand) { 6604 DartObjectImpl rightOperand) {
6710 if (expected == null) { 6605 if (expected == null) {
6711 try { 6606 try {
6712 leftOperand.minus(_typeProvider, rightOperand); 6607 leftOperand.minus(_typeProvider, rightOperand);
6713 JUnitTestCase.fail("Expected an EvaluationException"); 6608 fail("Expected an EvaluationException");
6714 } on EvaluationException catch (exception) { 6609 } on EvaluationException catch (exception) {
6715 } 6610 }
6716 } else { 6611 } else {
6717 DartObjectImpl result = leftOperand.minus(_typeProvider, rightOperand); 6612 DartObjectImpl result = leftOperand.minus(_typeProvider, rightOperand);
6718 JUnitTestCase.assertNotNull(result); 6613 expect(result, isNotNull);
6719 JUnitTestCase.assertEquals(expected, result); 6614 expect(result, expected);
6720 } 6615 }
6721 } 6616 }
6722 6617
6723 /** 6618 /**
6724 * Assert that the negation of the operand is the expected value, or that the operation throws an 6619 * Assert that the negation of the operand is the expected value, or that the operation throws an
6725 * exception if the expected value is `null`. 6620 * exception if the expected value is `null`.
6726 * 6621 *
6727 * @param expected the expected result of the operation 6622 * @param expected the expected result of the operation
6728 * @param operand the operand to the operation 6623 * @param operand the operand to the operation
6729 * @throws EvaluationException if the result is an exception when it should no t be 6624 * @throws EvaluationException if the result is an exception when it should no t be
6730 */ 6625 */
6731 void _assertNegated(DartObjectImpl expected, DartObjectImpl operand) { 6626 void _assertNegated(DartObjectImpl expected, DartObjectImpl operand) {
6732 if (expected == null) { 6627 if (expected == null) {
6733 try { 6628 try {
6734 operand.negated(_typeProvider); 6629 operand.negated(_typeProvider);
6735 JUnitTestCase.fail("Expected an EvaluationException"); 6630 fail("Expected an EvaluationException");
6736 } on EvaluationException catch (exception) { 6631 } on EvaluationException catch (exception) {
6737 } 6632 }
6738 } else { 6633 } else {
6739 DartObjectImpl result = operand.negated(_typeProvider); 6634 DartObjectImpl result = operand.negated(_typeProvider);
6740 JUnitTestCase.assertNotNull(result); 6635 expect(result, isNotNull);
6741 JUnitTestCase.assertEquals(expected, result); 6636 expect(result, expected);
6742 } 6637 }
6743 } 6638 }
6744 6639
6745 /** 6640 /**
6746 * Assert that the result of comparing the left and right operands for inequal ity is the expected 6641 * Assert that the result of comparing the left and right operands for inequal ity is the expected
6747 * value, or that the operation throws an exception if the expected value is ` null`. 6642 * value, or that the operation throws an exception if the expected value is ` null`.
6748 * 6643 *
6749 * @param expected the expected result of the operation 6644 * @param expected the expected result of the operation
6750 * @param leftOperand the left operand to the operation 6645 * @param leftOperand the left operand to the operation
6751 * @param rightOperand the left operand to the operation 6646 * @param rightOperand the left operand to the operation
6752 * @throws EvaluationException if the result is an exception when it should no t be 6647 * @throws EvaluationException if the result is an exception when it should no t be
6753 */ 6648 */
6754 void _assertNotEqual(DartObjectImpl expected, DartObjectImpl leftOperand, 6649 void _assertNotEqual(DartObjectImpl expected, DartObjectImpl leftOperand,
6755 DartObjectImpl rightOperand) { 6650 DartObjectImpl rightOperand) {
6756 if (expected == null) { 6651 if (expected == null) {
6757 try { 6652 try {
6758 leftOperand.notEqual(_typeProvider, rightOperand); 6653 leftOperand.notEqual(_typeProvider, rightOperand);
6759 JUnitTestCase.fail("Expected an EvaluationException"); 6654 fail("Expected an EvaluationException");
6760 } on EvaluationException catch (exception) { 6655 } on EvaluationException catch (exception) {
6761 } 6656 }
6762 } else { 6657 } else {
6763 DartObjectImpl result = leftOperand.notEqual(_typeProvider, rightOperand); 6658 DartObjectImpl result = leftOperand.notEqual(_typeProvider, rightOperand);
6764 JUnitTestCase.assertNotNull(result); 6659 expect(result, isNotNull);
6765 JUnitTestCase.assertEquals(expected, result); 6660 expect(result, expected);
6766 } 6661 }
6767 } 6662 }
6768 6663
6769 /** 6664 /**
6770 * Assert that converting the operand to a string is the expected value, or th at the operation 6665 * Assert that converting the operand to a string is the expected value, or th at the operation
6771 * throws an exception if the expected value is `null`. 6666 * throws an exception if the expected value is `null`.
6772 * 6667 *
6773 * @param expected the expected result of the operation 6668 * @param expected the expected result of the operation
6774 * @param operand the operand to the operation 6669 * @param operand the operand to the operation
6775 * @throws EvaluationException if the result is an exception when it should no t be 6670 * @throws EvaluationException if the result is an exception when it should no t be
6776 */ 6671 */
6777 void _assertPerformToString(DartObjectImpl expected, DartObjectImpl operand) { 6672 void _assertPerformToString(DartObjectImpl expected, DartObjectImpl operand) {
6778 if (expected == null) { 6673 if (expected == null) {
6779 try { 6674 try {
6780 operand.performToString(_typeProvider); 6675 operand.performToString(_typeProvider);
6781 JUnitTestCase.fail("Expected an EvaluationException"); 6676 fail("Expected an EvaluationException");
6782 } on EvaluationException catch (exception) { 6677 } on EvaluationException catch (exception) {
6783 } 6678 }
6784 } else { 6679 } else {
6785 DartObjectImpl result = operand.performToString(_typeProvider); 6680 DartObjectImpl result = operand.performToString(_typeProvider);
6786 JUnitTestCase.assertNotNull(result); 6681 expect(result, isNotNull);
6787 JUnitTestCase.assertEquals(expected, result); 6682 expect(result, expected);
6788 } 6683 }
6789 } 6684 }
6790 6685
6791 /** 6686 /**
6792 * Assert that the result of taking the remainder of the left and right operan ds is the expected 6687 * Assert that the result of taking the remainder of the left and right operan ds is the expected
6793 * value, or that the operation throws an exception if the expected value is ` null`. 6688 * value, or that the operation throws an exception if the expected value is ` null`.
6794 * 6689 *
6795 * @param expected the expected result of the operation 6690 * @param expected the expected result of the operation
6796 * @param leftOperand the left operand to the operation 6691 * @param leftOperand the left operand to the operation
6797 * @param rightOperand the left operand to the operation 6692 * @param rightOperand the left operand to the operation
6798 * @throws EvaluationException if the result is an exception when it should no t be 6693 * @throws EvaluationException if the result is an exception when it should no t be
6799 */ 6694 */
6800 void _assertRemainder(DartObjectImpl expected, DartObjectImpl leftOperand, 6695 void _assertRemainder(DartObjectImpl expected, DartObjectImpl leftOperand,
6801 DartObjectImpl rightOperand) { 6696 DartObjectImpl rightOperand) {
6802 if (expected == null) { 6697 if (expected == null) {
6803 try { 6698 try {
6804 leftOperand.remainder(_typeProvider, rightOperand); 6699 leftOperand.remainder(_typeProvider, rightOperand);
6805 JUnitTestCase.fail("Expected an EvaluationException"); 6700 fail("Expected an EvaluationException");
6806 } on EvaluationException catch (exception) { 6701 } on EvaluationException catch (exception) {
6807 } 6702 }
6808 } else { 6703 } else {
6809 DartObjectImpl result = 6704 DartObjectImpl result =
6810 leftOperand.remainder(_typeProvider, rightOperand); 6705 leftOperand.remainder(_typeProvider, rightOperand);
6811 JUnitTestCase.assertNotNull(result); 6706 expect(result, isNotNull);
6812 JUnitTestCase.assertEquals(expected, result); 6707 expect(result, expected);
6813 } 6708 }
6814 } 6709 }
6815 6710
6816 /** 6711 /**
6817 * Assert that the result of multiplying the left and right operands is the ex pected value, or 6712 * Assert that the result of multiplying the left and right operands is the ex pected value, or
6818 * that the operation throws an exception if the expected value is `null`. 6713 * that the operation throws an exception if the expected value is `null`.
6819 * 6714 *
6820 * @param expected the expected result of the operation 6715 * @param expected the expected result of the operation
6821 * @param leftOperand the left operand to the operation 6716 * @param leftOperand the left operand to the operation
6822 * @param rightOperand the left operand to the operation 6717 * @param rightOperand the left operand to the operation
6823 * @throws EvaluationException if the result is an exception when it should no t be 6718 * @throws EvaluationException if the result is an exception when it should no t be
6824 */ 6719 */
6825 void _assertShiftLeft(DartObjectImpl expected, DartObjectImpl leftOperand, 6720 void _assertShiftLeft(DartObjectImpl expected, DartObjectImpl leftOperand,
6826 DartObjectImpl rightOperand) { 6721 DartObjectImpl rightOperand) {
6827 if (expected == null) { 6722 if (expected == null) {
6828 try { 6723 try {
6829 leftOperand.shiftLeft(_typeProvider, rightOperand); 6724 leftOperand.shiftLeft(_typeProvider, rightOperand);
6830 JUnitTestCase.fail("Expected an EvaluationException"); 6725 fail("Expected an EvaluationException");
6831 } on EvaluationException catch (exception) { 6726 } on EvaluationException catch (exception) {
6832 } 6727 }
6833 } else { 6728 } else {
6834 DartObjectImpl result = 6729 DartObjectImpl result =
6835 leftOperand.shiftLeft(_typeProvider, rightOperand); 6730 leftOperand.shiftLeft(_typeProvider, rightOperand);
6836 JUnitTestCase.assertNotNull(result); 6731 expect(result, isNotNull);
6837 JUnitTestCase.assertEquals(expected, result); 6732 expect(result, expected);
6838 } 6733 }
6839 } 6734 }
6840 6735
6841 /** 6736 /**
6842 * Assert that the result of multiplying the left and right operands is the ex pected value, or 6737 * Assert that the result of multiplying the left and right operands is the ex pected value, or
6843 * that the operation throws an exception if the expected value is `null`. 6738 * that the operation throws an exception if the expected value is `null`.
6844 * 6739 *
6845 * @param expected the expected result of the operation 6740 * @param expected the expected result of the operation
6846 * @param leftOperand the left operand to the operation 6741 * @param leftOperand the left operand to the operation
6847 * @param rightOperand the left operand to the operation 6742 * @param rightOperand the left operand to the operation
6848 * @throws EvaluationException if the result is an exception when it should no t be 6743 * @throws EvaluationException if the result is an exception when it should no t be
6849 */ 6744 */
6850 void _assertShiftRight(DartObjectImpl expected, DartObjectImpl leftOperand, 6745 void _assertShiftRight(DartObjectImpl expected, DartObjectImpl leftOperand,
6851 DartObjectImpl rightOperand) { 6746 DartObjectImpl rightOperand) {
6852 if (expected == null) { 6747 if (expected == null) {
6853 try { 6748 try {
6854 leftOperand.shiftRight(_typeProvider, rightOperand); 6749 leftOperand.shiftRight(_typeProvider, rightOperand);
6855 JUnitTestCase.fail("Expected an EvaluationException"); 6750 fail("Expected an EvaluationException");
6856 } on EvaluationException catch (exception) { 6751 } on EvaluationException catch (exception) {
6857 } 6752 }
6858 } else { 6753 } else {
6859 DartObjectImpl result = 6754 DartObjectImpl result =
6860 leftOperand.shiftRight(_typeProvider, rightOperand); 6755 leftOperand.shiftRight(_typeProvider, rightOperand);
6861 JUnitTestCase.assertNotNull(result); 6756 expect(result, isNotNull);
6862 JUnitTestCase.assertEquals(expected, result); 6757 expect(result, expected);
6863 } 6758 }
6864 } 6759 }
6865 6760
6866 /** 6761 /**
6867 * Assert that the length of the operand is the expected value, or that the op eration throws an 6762 * Assert that the length of the operand is the expected value, or that the op eration throws an
6868 * exception if the expected value is `null`. 6763 * exception if the expected value is `null`.
6869 * 6764 *
6870 * @param expected the expected result of the operation 6765 * @param expected the expected result of the operation
6871 * @param operand the operand to the operation 6766 * @param operand the operand to the operation
6872 * @throws EvaluationException if the result is an exception when it should no t be 6767 * @throws EvaluationException if the result is an exception when it should no t be
6873 */ 6768 */
6874 void _assertStringLength(DartObjectImpl expected, DartObjectImpl operand) { 6769 void _assertStringLength(DartObjectImpl expected, DartObjectImpl operand) {
6875 if (expected == null) { 6770 if (expected == null) {
6876 try { 6771 try {
6877 operand.stringLength(_typeProvider); 6772 operand.stringLength(_typeProvider);
6878 JUnitTestCase.fail("Expected an EvaluationException"); 6773 fail("Expected an EvaluationException");
6879 } on EvaluationException catch (exception) { 6774 } on EvaluationException catch (exception) {
6880 } 6775 }
6881 } else { 6776 } else {
6882 DartObjectImpl result = operand.stringLength(_typeProvider); 6777 DartObjectImpl result = operand.stringLength(_typeProvider);
6883 JUnitTestCase.assertNotNull(result); 6778 expect(result, isNotNull);
6884 JUnitTestCase.assertEquals(expected, result); 6779 expect(result, expected);
6885 } 6780 }
6886 } 6781 }
6887 6782
6888 /** 6783 /**
6889 * Assert that the result of multiplying the left and right operands is the ex pected value, or 6784 * Assert that the result of multiplying the left and right operands is the ex pected value, or
6890 * that the operation throws an exception if the expected value is `null`. 6785 * that the operation throws an exception if the expected value is `null`.
6891 * 6786 *
6892 * @param expected the expected result of the operation 6787 * @param expected the expected result of the operation
6893 * @param leftOperand the left operand to the operation 6788 * @param leftOperand the left operand to the operation
6894 * @param rightOperand the left operand to the operation 6789 * @param rightOperand the left operand to the operation
6895 * @throws EvaluationException if the result is an exception when it should no t be 6790 * @throws EvaluationException if the result is an exception when it should no t be
6896 */ 6791 */
6897 void _assertTimes(DartObjectImpl expected, DartObjectImpl leftOperand, 6792 void _assertTimes(DartObjectImpl expected, DartObjectImpl leftOperand,
6898 DartObjectImpl rightOperand) { 6793 DartObjectImpl rightOperand) {
6899 if (expected == null) { 6794 if (expected == null) {
6900 try { 6795 try {
6901 leftOperand.times(_typeProvider, rightOperand); 6796 leftOperand.times(_typeProvider, rightOperand);
6902 JUnitTestCase.fail("Expected an EvaluationException"); 6797 fail("Expected an EvaluationException");
6903 } on EvaluationException catch (exception) { 6798 } on EvaluationException catch (exception) {
6904 } 6799 }
6905 } else { 6800 } else {
6906 DartObjectImpl result = leftOperand.times(_typeProvider, rightOperand); 6801 DartObjectImpl result = leftOperand.times(_typeProvider, rightOperand);
6907 JUnitTestCase.assertNotNull(result); 6802 expect(result, isNotNull);
6908 JUnitTestCase.assertEquals(expected, result); 6803 expect(result, expected);
6909 } 6804 }
6910 } 6805 }
6911 6806
6912 DartObjectImpl _boolValue(bool value) { 6807 DartObjectImpl _boolValue(bool value) {
6913 if (value == null) { 6808 if (value == null) {
6914 return new DartObjectImpl( 6809 return new DartObjectImpl(
6915 _typeProvider.boolType, 6810 _typeProvider.boolType,
6916 BoolState.UNKNOWN_VALUE); 6811 BoolState.UNKNOWN_VALUE);
6917 } else if (identical(value, false)) { 6812 } else if (identical(value, false)) {
6918 return new DartObjectImpl(_typeProvider.boolType, BoolState.FALSE_STATE); 6813 return new DartObjectImpl(_typeProvider.boolType, BoolState.FALSE_STATE);
6919 } else if (identical(value, true)) { 6814 } else if (identical(value, true)) {
6920 return new DartObjectImpl(_typeProvider.boolType, BoolState.TRUE_STATE); 6815 return new DartObjectImpl(_typeProvider.boolType, BoolState.TRUE_STATE);
6921 } 6816 }
6922 JUnitTestCase.fail("Invalid boolean value used in test"); 6817 fail("Invalid boolean value used in test");
6923 return null; 6818 return null;
6924 } 6819 }
6925 6820
6926 DartObjectImpl _doubleValue(double value) { 6821 DartObjectImpl _doubleValue(double value) {
6927 if (value == null) { 6822 if (value == null) {
6928 return new DartObjectImpl( 6823 return new DartObjectImpl(
6929 _typeProvider.doubleType, 6824 _typeProvider.doubleType,
6930 DoubleState.UNKNOWN_VALUE); 6825 DoubleState.UNKNOWN_VALUE);
6931 } else { 6826 } else {
6932 return new DartObjectImpl( 6827 return new DartObjectImpl(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6982 new StringState(value)); 6877 new StringState(value));
6983 } 6878 }
6984 } 6879 }
6985 6880
6986 DartObjectImpl _symbolValue(String value) { 6881 DartObjectImpl _symbolValue(String value) {
6987 return new DartObjectImpl(_typeProvider.symbolType, new SymbolState(value)); 6882 return new DartObjectImpl(_typeProvider.symbolType, new SymbolState(value));
6988 } 6883 }
6989 } 6884 }
6990 6885
6991 6886
6992 class DartUriResolverTest extends JUnitTestCase { 6887 class DartUriResolverTest {
6993 void test_creation() { 6888 void test_creation() {
6994 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 6889 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
6995 JUnitTestCase.assertNotNull(sdkDirectory); 6890 expect(sdkDirectory, isNotNull);
6996 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 6891 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
6997 JUnitTestCase.assertNotNull(new DartUriResolver(sdk)); 6892 expect(new DartUriResolver(sdk), isNotNull);
6998 } 6893 }
6999 6894
7000 void test_isDartUri_null_scheme() { 6895 void test_isDartUri_null_scheme() {
7001 Uri uri = parseUriWithException("foo.dart"); 6896 Uri uri = parseUriWithException("foo.dart");
7002 JUnitTestCase.assertEquals(uri.scheme, ''); 6897 expect('', uri.scheme);
7003 JUnitTestCase.assertFalse(DartUriResolver.isDartUri(uri)); 6898 expect(DartUriResolver.isDartUri(uri), isFalse);
7004 } 6899 }
7005 6900
7006 void test_resolve_dart() { 6901 void test_resolve_dart() {
7007 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 6902 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
7008 JUnitTestCase.assertNotNull(sdkDirectory); 6903 expect(sdkDirectory, isNotNull);
7009 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 6904 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
7010 UriResolver resolver = new DartUriResolver(sdk); 6905 UriResolver resolver = new DartUriResolver(sdk);
7011 Source result = 6906 Source result =
7012 resolver.resolveAbsolute(parseUriWithException("dart:core")); 6907 resolver.resolveAbsolute(parseUriWithException("dart:core"));
7013 JUnitTestCase.assertNotNull(result); 6908 expect(result, isNotNull);
7014 } 6909 }
7015 6910
7016 void test_resolve_dart_nonExistingLibrary() { 6911 void test_resolve_dart_nonExistingLibrary() {
7017 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 6912 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
7018 JUnitTestCase.assertNotNull(sdkDirectory); 6913 expect(sdkDirectory, isNotNull);
7019 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 6914 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
7020 UriResolver resolver = new DartUriResolver(sdk); 6915 UriResolver resolver = new DartUriResolver(sdk);
7021 Source result = resolver.resolveAbsolute(parseUriWithException("dart:cor")); 6916 Source result = resolver.resolveAbsolute(parseUriWithException("dart:cor"));
7022 JUnitTestCase.assertNull(result); 6917 expect(result, isNull);
7023 } 6918 }
7024 6919
7025 void test_resolve_nonDart() { 6920 void test_resolve_nonDart() {
7026 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 6921 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
7027 JUnitTestCase.assertNotNull(sdkDirectory); 6922 expect(sdkDirectory, isNotNull);
7028 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 6923 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
7029 UriResolver resolver = new DartUriResolver(sdk); 6924 UriResolver resolver = new DartUriResolver(sdk);
7030 Source result = 6925 Source result =
7031 resolver.resolveAbsolute(parseUriWithException("package:some/file.dart") ); 6926 resolver.resolveAbsolute(parseUriWithException("package:some/file.dart") );
7032 JUnitTestCase.assertNull(result); 6927 expect(result, isNull);
7033 } 6928 }
7034 } 6929 }
7035 6930
7036 6931
7037 class DeclaredVariablesTest extends EngineTestCase { 6932 class DeclaredVariablesTest extends EngineTestCase {
7038 void test_getBool_false() { 6933 void test_getBool_false() {
7039 TestTypeProvider typeProvider = new TestTypeProvider(); 6934 TestTypeProvider typeProvider = new TestTypeProvider();
7040 String variableName = "var"; 6935 String variableName = "var";
7041 DeclaredVariables variables = new DeclaredVariables(); 6936 DeclaredVariables variables = new DeclaredVariables();
7042 variables.define(variableName, "false"); 6937 variables.define(variableName, "false");
7043 DartObject object = variables.getBool(typeProvider, variableName); 6938 DartObject object = variables.getBool(typeProvider, variableName);
7044 JUnitTestCase.assertNotNull(object); 6939 expect(object, isNotNull);
7045 JUnitTestCase.assertEquals(false, object.boolValue); 6940 expect(object.boolValue, false);
7046 } 6941 }
7047 6942
7048 void test_getBool_invalid() { 6943 void test_getBool_invalid() {
7049 TestTypeProvider typeProvider = new TestTypeProvider(); 6944 TestTypeProvider typeProvider = new TestTypeProvider();
7050 String variableName = "var"; 6945 String variableName = "var";
7051 DeclaredVariables variables = new DeclaredVariables(); 6946 DeclaredVariables variables = new DeclaredVariables();
7052 variables.define(variableName, "not true"); 6947 variables.define(variableName, "not true");
7053 _assertNullDartObject( 6948 _assertNullDartObject(
7054 typeProvider, 6949 typeProvider,
7055 variables.getBool(typeProvider, variableName)); 6950 variables.getBool(typeProvider, variableName));
7056 } 6951 }
7057 6952
7058 void test_getBool_true() { 6953 void test_getBool_true() {
7059 TestTypeProvider typeProvider = new TestTypeProvider(); 6954 TestTypeProvider typeProvider = new TestTypeProvider();
7060 String variableName = "var"; 6955 String variableName = "var";
7061 DeclaredVariables variables = new DeclaredVariables(); 6956 DeclaredVariables variables = new DeclaredVariables();
7062 variables.define(variableName, "true"); 6957 variables.define(variableName, "true");
7063 DartObject object = variables.getBool(typeProvider, variableName); 6958 DartObject object = variables.getBool(typeProvider, variableName);
7064 JUnitTestCase.assertNotNull(object); 6959 expect(object, isNotNull);
7065 JUnitTestCase.assertEquals(true, object.boolValue); 6960 expect(object.boolValue, true);
7066 } 6961 }
7067 6962
7068 void test_getBool_undefined() { 6963 void test_getBool_undefined() {
7069 TestTypeProvider typeProvider = new TestTypeProvider(); 6964 TestTypeProvider typeProvider = new TestTypeProvider();
7070 String variableName = "var"; 6965 String variableName = "var";
7071 DeclaredVariables variables = new DeclaredVariables(); 6966 DeclaredVariables variables = new DeclaredVariables();
7072 _assertUnknownDartObject(typeProvider.boolType, 6967 _assertUnknownDartObject(typeProvider.boolType,
7073 variables.getBool(typeProvider, variableName)); 6968 variables.getBool(typeProvider, variableName));
7074 } 6969 }
7075 6970
(...skipping 14 matching lines...) Expand all
7090 _assertUnknownDartObject(typeProvider.intType, 6985 _assertUnknownDartObject(typeProvider.intType,
7091 variables.getInt(typeProvider, variableName)); 6986 variables.getInt(typeProvider, variableName));
7092 } 6987 }
7093 6988
7094 void test_getInt_valid() { 6989 void test_getInt_valid() {
7095 TestTypeProvider typeProvider = new TestTypeProvider(); 6990 TestTypeProvider typeProvider = new TestTypeProvider();
7096 String variableName = "var"; 6991 String variableName = "var";
7097 DeclaredVariables variables = new DeclaredVariables(); 6992 DeclaredVariables variables = new DeclaredVariables();
7098 variables.define(variableName, "23"); 6993 variables.define(variableName, "23");
7099 DartObject object = variables.getInt(typeProvider, variableName); 6994 DartObject object = variables.getInt(typeProvider, variableName);
7100 JUnitTestCase.assertNotNull(object); 6995 expect(object, isNotNull);
7101 JUnitTestCase.assertEquals(23, object.intValue); 6996 expect(object.intValue, 23);
7102 } 6997 }
7103 6998
7104 void test_getString_defined() { 6999 void test_getString_defined() {
7105 TestTypeProvider typeProvider = new TestTypeProvider(); 7000 TestTypeProvider typeProvider = new TestTypeProvider();
7106 String variableName = "var"; 7001 String variableName = "var";
7107 String value = "value"; 7002 String value = "value";
7108 DeclaredVariables variables = new DeclaredVariables(); 7003 DeclaredVariables variables = new DeclaredVariables();
7109 variables.define(variableName, value); 7004 variables.define(variableName, value);
7110 DartObject object = variables.getString(typeProvider, variableName); 7005 DartObject object = variables.getString(typeProvider, variableName);
7111 JUnitTestCase.assertNotNull(object); 7006 expect(object, isNotNull);
7112 JUnitTestCase.assertEquals(value, object.stringValue); 7007 expect(object.stringValue, value);
7113 } 7008 }
7114 7009
7115 void test_getString_undefined() { 7010 void test_getString_undefined() {
7116 TestTypeProvider typeProvider = new TestTypeProvider(); 7011 TestTypeProvider typeProvider = new TestTypeProvider();
7117 String variableName = "var"; 7012 String variableName = "var";
7118 DeclaredVariables variables = new DeclaredVariables(); 7013 DeclaredVariables variables = new DeclaredVariables();
7119 _assertUnknownDartObject(typeProvider.stringType, 7014 _assertUnknownDartObject(typeProvider.stringType,
7120 variables.getString(typeProvider, variableName)); 7015 variables.getString(typeProvider, variableName));
7121 } 7016 }
7122 7017
7123 void _assertNullDartObject(TestTypeProvider typeProvider, DartObject result) { 7018 void _assertNullDartObject(TestTypeProvider typeProvider, DartObject result) {
7124 JUnitTestCase.assertEquals(typeProvider.nullType, result.type); 7019 expect(result.type, typeProvider.nullType);
7125 } 7020 }
7126 7021
7127 void _assertUnknownDartObject(ParameterizedType expectedType, 7022 void _assertUnknownDartObject(ParameterizedType expectedType,
7128 DartObject result) { 7023 DartObject result) {
7129 JUnitTestCase.assertTrue((result as DartObjectImpl).isUnknown); 7024 expect((result as DartObjectImpl).isUnknown, isTrue);
7130 JUnitTestCase.assertEquals(expectedType, result.type); 7025 expect(result.type, expectedType);
7131 } 7026 }
7132 } 7027 }
7133 7028
7134 7029
7135 class DirectoryBasedDartSdkTest extends JUnitTestCase { 7030 class DirectoryBasedDartSdkTest {
7136 void fail_getDocFileFor() { 7031 void fail_getDocFileFor() {
7137 DirectoryBasedDartSdk sdk = _createDartSdk(); 7032 DirectoryBasedDartSdk sdk = _createDartSdk();
7138 JavaFile docFile = sdk.getDocFileFor("html"); 7033 JavaFile docFile = sdk.getDocFileFor("html");
7139 JUnitTestCase.assertNotNull(docFile); 7034 expect(docFile, isNotNull);
7140 } 7035 }
7141 7036
7142 void test_creation() { 7037 void test_creation() {
7143 DirectoryBasedDartSdk sdk = _createDartSdk(); 7038 DirectoryBasedDartSdk sdk = _createDartSdk();
7144 JUnitTestCase.assertNotNull(sdk); 7039 expect(sdk, isNotNull);
7145 } 7040 }
7146 7041
7147 void test_fromFile_invalid() { 7042 void test_fromFile_invalid() {
7148 DirectoryBasedDartSdk sdk = _createDartSdk(); 7043 DirectoryBasedDartSdk sdk = _createDartSdk();
7149 JUnitTestCase.assertNull( 7044 expect(sdk.fromFileUri(new JavaFile("/not/in/the/sdk.dart").toURI()), isNull );
7150 sdk.fromFileUri(new JavaFile("/not/in/the/sdk.dart").toURI()));
7151 } 7045 }
7152 7046
7153 void test_fromFile_library() { 7047 void test_fromFile_library() {
7154 DirectoryBasedDartSdk sdk = _createDartSdk(); 7048 DirectoryBasedDartSdk sdk = _createDartSdk();
7155 Source source = sdk.fromFileUri( 7049 Source source = sdk.fromFileUri(
7156 new JavaFile.relative( 7050 new JavaFile.relative(
7157 new JavaFile.relative(sdk.libraryDirectory, "core"), 7051 new JavaFile.relative(sdk.libraryDirectory, "core"),
7158 "core.dart").toURI()); 7052 "core.dart").toURI());
7159 JUnitTestCase.assertNotNull(source); 7053 expect(source, isNotNull);
7160 JUnitTestCase.assertTrue(source.isInSystemLibrary); 7054 expect(source.isInSystemLibrary, isTrue);
7161 JUnitTestCase.assertEquals("dart:core", source.uri.toString()); 7055 expect(source.uri.toString(), "dart:core");
7162 } 7056 }
7163 7057
7164 void test_fromFile_part() { 7058 void test_fromFile_part() {
7165 DirectoryBasedDartSdk sdk = _createDartSdk(); 7059 DirectoryBasedDartSdk sdk = _createDartSdk();
7166 Source source = sdk.fromFileUri( 7060 Source source = sdk.fromFileUri(
7167 new JavaFile.relative( 7061 new JavaFile.relative(
7168 new JavaFile.relative(sdk.libraryDirectory, "core"), 7062 new JavaFile.relative(sdk.libraryDirectory, "core"),
7169 "num.dart").toURI()); 7063 "num.dart").toURI());
7170 JUnitTestCase.assertNotNull(source); 7064 expect(source, isNotNull);
7171 JUnitTestCase.assertTrue(source.isInSystemLibrary); 7065 expect(source.isInSystemLibrary, isTrue);
7172 JUnitTestCase.assertEquals("dart:core/num.dart", source.uri.toString()); 7066 expect(source.uri.toString(), "dart:core/num.dart");
7173 } 7067 }
7174 7068
7175 void test_getDart2JsExecutable() { 7069 void test_getDart2JsExecutable() {
7176 DirectoryBasedDartSdk sdk = _createDartSdk(); 7070 DirectoryBasedDartSdk sdk = _createDartSdk();
7177 JavaFile executable = sdk.dart2JsExecutable; 7071 JavaFile executable = sdk.dart2JsExecutable;
7178 JUnitTestCase.assertNotNull(executable); 7072 expect(executable, isNotNull);
7179 JUnitTestCase.assertTrue(executable.exists()); 7073 expect(executable.exists(), isTrue);
7180 JUnitTestCase.assertTrue(executable.isExecutable()); 7074 expect(executable.isExecutable(), isTrue);
7181 } 7075 }
7182 7076
7183 void test_getDartFmtExecutable() { 7077 void test_getDartFmtExecutable() {
7184 DirectoryBasedDartSdk sdk = _createDartSdk(); 7078 DirectoryBasedDartSdk sdk = _createDartSdk();
7185 JavaFile executable = sdk.dartFmtExecutable; 7079 JavaFile executable = sdk.dartFmtExecutable;
7186 JUnitTestCase.assertNotNull(executable); 7080 expect(executable, isNotNull);
7187 JUnitTestCase.assertTrue(executable.exists()); 7081 expect(executable.exists(), isTrue);
7188 JUnitTestCase.assertTrue(executable.isExecutable()); 7082 expect(executable.isExecutable(), isTrue);
7189 } 7083 }
7190 7084
7191 void test_getDirectory() { 7085 void test_getDirectory() {
7192 DirectoryBasedDartSdk sdk = _createDartSdk(); 7086 DirectoryBasedDartSdk sdk = _createDartSdk();
7193 JavaFile directory = sdk.directory; 7087 JavaFile directory = sdk.directory;
7194 JUnitTestCase.assertNotNull(directory); 7088 expect(directory, isNotNull);
7195 JUnitTestCase.assertTrue(directory.exists()); 7089 expect(directory.exists(), isTrue);
7196 } 7090 }
7197 7091
7198 void test_getDocDirectory() { 7092 void test_getDocDirectory() {
7199 DirectoryBasedDartSdk sdk = _createDartSdk(); 7093 DirectoryBasedDartSdk sdk = _createDartSdk();
7200 JavaFile directory = sdk.docDirectory; 7094 JavaFile directory = sdk.docDirectory;
7201 JUnitTestCase.assertNotNull(directory); 7095 expect(directory, isNotNull);
7202 } 7096 }
7203 7097
7204 void test_getLibraryDirectory() { 7098 void test_getLibraryDirectory() {
7205 DirectoryBasedDartSdk sdk = _createDartSdk(); 7099 DirectoryBasedDartSdk sdk = _createDartSdk();
7206 JavaFile directory = sdk.libraryDirectory; 7100 JavaFile directory = sdk.libraryDirectory;
7207 JUnitTestCase.assertNotNull(directory); 7101 expect(directory, isNotNull);
7208 JUnitTestCase.assertTrue(directory.exists()); 7102 expect(directory.exists(), isTrue);
7209 } 7103 }
7210 7104
7211 void test_getPubExecutable() { 7105 void test_getPubExecutable() {
7212 DirectoryBasedDartSdk sdk = _createDartSdk(); 7106 DirectoryBasedDartSdk sdk = _createDartSdk();
7213 JavaFile executable = sdk.pubExecutable; 7107 JavaFile executable = sdk.pubExecutable;
7214 JUnitTestCase.assertNotNull(executable); 7108 expect(executable, isNotNull);
7215 JUnitTestCase.assertTrue(executable.exists()); 7109 expect(executable.exists(), isTrue);
7216 JUnitTestCase.assertTrue(executable.isExecutable()); 7110 expect(executable.isExecutable(), isTrue);
7217 } 7111 }
7218 7112
7219 void test_getSdkVersion() { 7113 void test_getSdkVersion() {
7220 DirectoryBasedDartSdk sdk = _createDartSdk(); 7114 DirectoryBasedDartSdk sdk = _createDartSdk();
7221 String version = sdk.sdkVersion; 7115 String version = sdk.sdkVersion;
7222 JUnitTestCase.assertNotNull(version); 7116 expect(version, isNotNull);
7223 JUnitTestCase.assertTrue(version.length > 0); 7117 expect(version.length > 0, isTrue);
7224 } 7118 }
7225 7119
7226 void test_getVmExecutable() { 7120 void test_getVmExecutable() {
7227 DirectoryBasedDartSdk sdk = _createDartSdk(); 7121 DirectoryBasedDartSdk sdk = _createDartSdk();
7228 JavaFile executable = sdk.vmExecutable; 7122 JavaFile executable = sdk.vmExecutable;
7229 JUnitTestCase.assertNotNull(executable); 7123 expect(executable, isNotNull);
7230 JUnitTestCase.assertTrue(executable.exists()); 7124 expect(executable.exists(), isTrue);
7231 JUnitTestCase.assertTrue(executable.isExecutable()); 7125 expect(executable.isExecutable(), isTrue);
7232 } 7126 }
7233 7127
7234 DirectoryBasedDartSdk _createDartSdk() { 7128 DirectoryBasedDartSdk _createDartSdk() {
7235 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 7129 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
7236 JUnitTestCase.assertNotNullMsg( 7130 expect(sdkDirectory, isNotNull, reason: "No SDK configured; set the property 'com.google.dart.sdk' on the command line");
7237 "No SDK configured; set the property 'com.google.dart.sdk' on the comman d line",
7238 sdkDirectory);
7239 return new DirectoryBasedDartSdk(sdkDirectory); 7131 return new DirectoryBasedDartSdk(sdkDirectory);
7240 } 7132 }
7241 } 7133 }
7242 7134
7243 7135
7244 class DirectoryBasedSourceContainerTest extends JUnitTestCase { 7136 class DirectoryBasedSourceContainerTest {
7245 void test_contains() { 7137 void test_contains() {
7246 JavaFile dir = FileUtilities2.createFile("/does/not/exist"); 7138 JavaFile dir = FileUtilities2.createFile("/does/not/exist");
7247 JavaFile file1 = FileUtilities2.createFile("/does/not/exist/some.dart"); 7139 JavaFile file1 = FileUtilities2.createFile("/does/not/exist/some.dart");
7248 JavaFile file2 = 7140 JavaFile file2 =
7249 FileUtilities2.createFile("/does/not/exist/folder/some2.dart"); 7141 FileUtilities2.createFile("/does/not/exist/folder/some2.dart");
7250 JavaFile file3 = FileUtilities2.createFile("/does/not/exist3/some3.dart"); 7142 JavaFile file3 = FileUtilities2.createFile("/does/not/exist3/some3.dart");
7251 FileBasedSource source1 = new FileBasedSource.con1(file1); 7143 FileBasedSource source1 = new FileBasedSource.con1(file1);
7252 FileBasedSource source2 = new FileBasedSource.con1(file2); 7144 FileBasedSource source2 = new FileBasedSource.con1(file2);
7253 FileBasedSource source3 = new FileBasedSource.con1(file3); 7145 FileBasedSource source3 = new FileBasedSource.con1(file3);
7254 DirectoryBasedSourceContainer container = 7146 DirectoryBasedSourceContainer container =
7255 new DirectoryBasedSourceContainer.con1(dir); 7147 new DirectoryBasedSourceContainer.con1(dir);
7256 JUnitTestCase.assertTrue(container.contains(source1)); 7148 expect(container.contains(source1), isTrue);
7257 JUnitTestCase.assertTrue(container.contains(source2)); 7149 expect(container.contains(source2), isTrue);
7258 JUnitTestCase.assertFalse(container.contains(source3)); 7150 expect(container.contains(source3), isFalse);
7259 } 7151 }
7260 } 7152 }
7261 7153
7262 7154
7263 class ElementBuilderTest extends EngineTestCase { 7155 class ElementBuilderTest extends EngineTestCase {
7264 void test_visitCatchClause() { 7156 void test_visitCatchClause() {
7265 ElementHolder holder = new ElementHolder(); 7157 ElementHolder holder = new ElementHolder();
7266 ElementBuilder builder = new ElementBuilder(holder); 7158 ElementBuilder builder = new ElementBuilder(holder);
7267 String exceptionParameterName = "e"; 7159 String exceptionParameterName = "e";
7268 String stackParameterName = "s"; 7160 String stackParameterName = "s";
7269 CatchClause clause = 7161 CatchClause clause =
7270 AstFactory.catchClause2(exceptionParameterName, stackParameterName, []); 7162 AstFactory.catchClause2(exceptionParameterName, stackParameterName, []);
7271 clause.accept(builder); 7163 clause.accept(builder);
7272 List<LocalVariableElement> variables = holder.localVariables; 7164 List<LocalVariableElement> variables = holder.localVariables;
7273 EngineTestCase.assertLength(2, variables); 7165 EngineTestCase.assertLength(2, variables);
7274 VariableElement exceptionVariable = variables[0]; 7166 VariableElement exceptionVariable = variables[0];
7275 JUnitTestCase.assertNotNull(exceptionVariable); 7167 expect(exceptionVariable, isNotNull);
7276 JUnitTestCase.assertEquals(exceptionParameterName, exceptionVariable.name); 7168 expect(exceptionVariable.name, exceptionParameterName);
7277 JUnitTestCase.assertFalse(exceptionVariable.isSynthetic); 7169 expect(exceptionVariable.isSynthetic, isFalse);
7278 JUnitTestCase.assertFalse(exceptionVariable.isConst); 7170 expect(exceptionVariable.isConst, isFalse);
7279 JUnitTestCase.assertFalse(exceptionVariable.isFinal); 7171 expect(exceptionVariable.isFinal, isFalse);
7280 JUnitTestCase.assertNull(exceptionVariable.initializer); 7172 expect(exceptionVariable.initializer, isNull);
7281 VariableElement stackVariable = variables[1]; 7173 VariableElement stackVariable = variables[1];
7282 JUnitTestCase.assertNotNull(stackVariable); 7174 expect(stackVariable, isNotNull);
7283 JUnitTestCase.assertEquals(stackParameterName, stackVariable.name); 7175 expect(stackVariable.name, stackParameterName);
7284 JUnitTestCase.assertFalse(stackVariable.isSynthetic); 7176 expect(stackVariable.isSynthetic, isFalse);
7285 JUnitTestCase.assertFalse(stackVariable.isConst); 7177 expect(stackVariable.isConst, isFalse);
7286 JUnitTestCase.assertFalse(stackVariable.isFinal); 7178 expect(stackVariable.isFinal, isFalse);
7287 JUnitTestCase.assertNull(stackVariable.initializer); 7179 expect(stackVariable.initializer, isNull);
7288 } 7180 }
7289 7181
7290 void test_visitClassDeclaration_abstract() { 7182 void test_visitClassDeclaration_abstract() {
7291 ElementHolder holder = new ElementHolder(); 7183 ElementHolder holder = new ElementHolder();
7292 ElementBuilder builder = new ElementBuilder(holder); 7184 ElementBuilder builder = new ElementBuilder(holder);
7293 String className = "C"; 7185 String className = "C";
7294 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 7186 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
7295 Keyword.ABSTRACT, 7187 Keyword.ABSTRACT,
7296 className, 7188 className,
7297 null, 7189 null,
7298 null, 7190 null,
7299 null, 7191 null,
7300 null, 7192 null,
7301 []); 7193 []);
7302 classDeclaration.accept(builder); 7194 classDeclaration.accept(builder);
7303 List<ClassElement> types = holder.types; 7195 List<ClassElement> types = holder.types;
7304 EngineTestCase.assertLength(1, types); 7196 EngineTestCase.assertLength(1, types);
7305 ClassElement type = types[0]; 7197 ClassElement type = types[0];
7306 JUnitTestCase.assertNotNull(type); 7198 expect(type, isNotNull);
7307 JUnitTestCase.assertEquals(className, type.name); 7199 expect(type.name, className);
7308 List<TypeParameterElement> typeParameters = type.typeParameters; 7200 List<TypeParameterElement> typeParameters = type.typeParameters;
7309 EngineTestCase.assertLength(0, typeParameters); 7201 EngineTestCase.assertLength(0, typeParameters);
7310 JUnitTestCase.assertTrue(type.isAbstract); 7202 expect(type.isAbstract, isTrue);
7311 JUnitTestCase.assertFalse(type.isSynthetic); 7203 expect(type.isSynthetic, isFalse);
7312 } 7204 }
7313 7205
7314 void test_visitClassDeclaration_minimal() { 7206 void test_visitClassDeclaration_minimal() {
7315 ElementHolder holder = new ElementHolder(); 7207 ElementHolder holder = new ElementHolder();
7316 ElementBuilder builder = new ElementBuilder(holder); 7208 ElementBuilder builder = new ElementBuilder(holder);
7317 String className = "C"; 7209 String className = "C";
7318 ClassDeclaration classDeclaration = 7210 ClassDeclaration classDeclaration =
7319 AstFactory.classDeclaration(null, className, null, null, null, null, []) ; 7211 AstFactory.classDeclaration(null, className, null, null, null, null, []) ;
7320 classDeclaration.accept(builder); 7212 classDeclaration.accept(builder);
7321 List<ClassElement> types = holder.types; 7213 List<ClassElement> types = holder.types;
7322 EngineTestCase.assertLength(1, types); 7214 EngineTestCase.assertLength(1, types);
7323 ClassElement type = types[0]; 7215 ClassElement type = types[0];
7324 JUnitTestCase.assertNotNull(type); 7216 expect(type, isNotNull);
7325 JUnitTestCase.assertEquals(className, type.name); 7217 expect(type.name, className);
7326 List<TypeParameterElement> typeParameters = type.typeParameters; 7218 List<TypeParameterElement> typeParameters = type.typeParameters;
7327 EngineTestCase.assertLength(0, typeParameters); 7219 EngineTestCase.assertLength(0, typeParameters);
7328 JUnitTestCase.assertFalse(type.isAbstract); 7220 expect(type.isAbstract, isFalse);
7329 JUnitTestCase.assertFalse(type.isSynthetic); 7221 expect(type.isSynthetic, isFalse);
7330 } 7222 }
7331 7223
7332 void test_visitClassDeclaration_parameterized() { 7224 void test_visitClassDeclaration_parameterized() {
7333 ElementHolder holder = new ElementHolder(); 7225 ElementHolder holder = new ElementHolder();
7334 ElementBuilder builder = new ElementBuilder(holder); 7226 ElementBuilder builder = new ElementBuilder(holder);
7335 String className = "C"; 7227 String className = "C";
7336 String firstVariableName = "E"; 7228 String firstVariableName = "E";
7337 String secondVariableName = "F"; 7229 String secondVariableName = "F";
7338 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 7230 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
7339 null, 7231 null,
7340 className, 7232 className,
7341 AstFactory.typeParameterList([firstVariableName, secondVariableName]), 7233 AstFactory.typeParameterList([firstVariableName, secondVariableName]),
7342 null, 7234 null,
7343 null, 7235 null,
7344 null, 7236 null,
7345 []); 7237 []);
7346 classDeclaration.accept(builder); 7238 classDeclaration.accept(builder);
7347 List<ClassElement> types = holder.types; 7239 List<ClassElement> types = holder.types;
7348 EngineTestCase.assertLength(1, types); 7240 EngineTestCase.assertLength(1, types);
7349 ClassElement type = types[0]; 7241 ClassElement type = types[0];
7350 JUnitTestCase.assertNotNull(type); 7242 expect(type, isNotNull);
7351 JUnitTestCase.assertEquals(className, type.name); 7243 expect(type.name, className);
7352 List<TypeParameterElement> typeParameters = type.typeParameters; 7244 List<TypeParameterElement> typeParameters = type.typeParameters;
7353 EngineTestCase.assertLength(2, typeParameters); 7245 EngineTestCase.assertLength(2, typeParameters);
7354 JUnitTestCase.assertEquals(firstVariableName, typeParameters[0].name); 7246 expect(typeParameters[0].name, firstVariableName);
7355 JUnitTestCase.assertEquals(secondVariableName, typeParameters[1].name); 7247 expect(typeParameters[1].name, secondVariableName);
7356 JUnitTestCase.assertFalse(type.isAbstract); 7248 expect(type.isAbstract, isFalse);
7357 JUnitTestCase.assertFalse(type.isSynthetic); 7249 expect(type.isSynthetic, isFalse);
7358 } 7250 }
7359 7251
7360 void test_visitClassDeclaration_withMembers() { 7252 void test_visitClassDeclaration_withMembers() {
7361 ElementHolder holder = new ElementHolder(); 7253 ElementHolder holder = new ElementHolder();
7362 ElementBuilder builder = new ElementBuilder(holder); 7254 ElementBuilder builder = new ElementBuilder(holder);
7363 String className = "C"; 7255 String className = "C";
7364 String typeParameterName = "E"; 7256 String typeParameterName = "E";
7365 String fieldName = "f"; 7257 String fieldName = "f";
7366 String methodName = "m"; 7258 String methodName = "m";
7367 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 7259 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
(...skipping 13 matching lines...) Expand all
7381 null, 7273 null,
7382 null, 7274 null,
7383 null, 7275 null,
7384 AstFactory.identifier3(methodName), 7276 AstFactory.identifier3(methodName),
7385 AstFactory.formalParameterList([]), 7277 AstFactory.formalParameterList([]),
7386 AstFactory.blockFunctionBody2([]))]); 7278 AstFactory.blockFunctionBody2([]))]);
7387 classDeclaration.accept(builder); 7279 classDeclaration.accept(builder);
7388 List<ClassElement> types = holder.types; 7280 List<ClassElement> types = holder.types;
7389 EngineTestCase.assertLength(1, types); 7281 EngineTestCase.assertLength(1, types);
7390 ClassElement type = types[0]; 7282 ClassElement type = types[0];
7391 JUnitTestCase.assertNotNull(type); 7283 expect(type, isNotNull);
7392 JUnitTestCase.assertEquals(className, type.name); 7284 expect(type.name, className);
7393 JUnitTestCase.assertFalse(type.isAbstract); 7285 expect(type.isAbstract, isFalse);
7394 JUnitTestCase.assertFalse(type.isSynthetic); 7286 expect(type.isSynthetic, isFalse);
7395 List<TypeParameterElement> typeParameters = type.typeParameters; 7287 List<TypeParameterElement> typeParameters = type.typeParameters;
7396 EngineTestCase.assertLength(1, typeParameters); 7288 EngineTestCase.assertLength(1, typeParameters);
7397 TypeParameterElement typeParameter = typeParameters[0]; 7289 TypeParameterElement typeParameter = typeParameters[0];
7398 JUnitTestCase.assertNotNull(typeParameter); 7290 expect(typeParameter, isNotNull);
7399 JUnitTestCase.assertEquals(typeParameterName, typeParameter.name); 7291 expect(typeParameter.name, typeParameterName);
7400 List<FieldElement> fields = type.fields; 7292 List<FieldElement> fields = type.fields;
7401 EngineTestCase.assertLength(1, fields); 7293 EngineTestCase.assertLength(1, fields);
7402 FieldElement field = fields[0]; 7294 FieldElement field = fields[0];
7403 JUnitTestCase.assertNotNull(field); 7295 expect(field, isNotNull);
7404 JUnitTestCase.assertEquals(fieldName, field.name); 7296 expect(field.name, fieldName);
7405 List<MethodElement> methods = type.methods; 7297 List<MethodElement> methods = type.methods;
7406 EngineTestCase.assertLength(1, methods); 7298 EngineTestCase.assertLength(1, methods);
7407 MethodElement method = methods[0]; 7299 MethodElement method = methods[0];
7408 JUnitTestCase.assertNotNull(method); 7300 expect(method, isNotNull);
7409 JUnitTestCase.assertEquals(methodName, method.name); 7301 expect(method.name, methodName);
7410 } 7302 }
7411 7303
7412 void test_visitConstructorDeclaration_factory() { 7304 void test_visitConstructorDeclaration_factory() {
7413 ElementHolder holder = new ElementHolder(); 7305 ElementHolder holder = new ElementHolder();
7414 ElementBuilder builder = new ElementBuilder(holder); 7306 ElementBuilder builder = new ElementBuilder(holder);
7415 String className = "A"; 7307 String className = "A";
7416 ConstructorDeclaration constructorDeclaration = 7308 ConstructorDeclaration constructorDeclaration =
7417 AstFactory.constructorDeclaration2( 7309 AstFactory.constructorDeclaration2(
7418 null, 7310 null,
7419 Keyword.FACTORY, 7311 Keyword.FACTORY,
7420 AstFactory.identifier3(className), 7312 AstFactory.identifier3(className),
7421 null, 7313 null,
7422 AstFactory.formalParameterList([]), 7314 AstFactory.formalParameterList([]),
7423 null, 7315 null,
7424 AstFactory.blockFunctionBody2([])); 7316 AstFactory.blockFunctionBody2([]));
7425 constructorDeclaration.accept(builder); 7317 constructorDeclaration.accept(builder);
7426 List<ConstructorElement> constructors = holder.constructors; 7318 List<ConstructorElement> constructors = holder.constructors;
7427 EngineTestCase.assertLength(1, constructors); 7319 EngineTestCase.assertLength(1, constructors);
7428 ConstructorElement constructor = constructors[0]; 7320 ConstructorElement constructor = constructors[0];
7429 JUnitTestCase.assertNotNull(constructor); 7321 expect(constructor, isNotNull);
7430 JUnitTestCase.assertTrue(constructor.isFactory); 7322 expect(constructor.isFactory, isTrue);
7431 JUnitTestCase.assertEquals("", constructor.name); 7323 expect(constructor.name, "");
7432 EngineTestCase.assertLength(0, constructor.functions); 7324 EngineTestCase.assertLength(0, constructor.functions);
7433 EngineTestCase.assertLength(0, constructor.labels); 7325 EngineTestCase.assertLength(0, constructor.labels);
7434 EngineTestCase.assertLength(0, constructor.localVariables); 7326 EngineTestCase.assertLength(0, constructor.localVariables);
7435 EngineTestCase.assertLength(0, constructor.parameters); 7327 EngineTestCase.assertLength(0, constructor.parameters);
7436 } 7328 }
7437 7329
7438 void test_visitConstructorDeclaration_minimal() { 7330 void test_visitConstructorDeclaration_minimal() {
7439 ElementHolder holder = new ElementHolder(); 7331 ElementHolder holder = new ElementHolder();
7440 ElementBuilder builder = new ElementBuilder(holder); 7332 ElementBuilder builder = new ElementBuilder(holder);
7441 String className = "A"; 7333 String className = "A";
7442 ConstructorDeclaration constructorDeclaration = 7334 ConstructorDeclaration constructorDeclaration =
7443 AstFactory.constructorDeclaration2( 7335 AstFactory.constructorDeclaration2(
7444 null, 7336 null,
7445 null, 7337 null,
7446 AstFactory.identifier3(className), 7338 AstFactory.identifier3(className),
7447 null, 7339 null,
7448 AstFactory.formalParameterList([]), 7340 AstFactory.formalParameterList([]),
7449 null, 7341 null,
7450 AstFactory.blockFunctionBody2([])); 7342 AstFactory.blockFunctionBody2([]));
7451 constructorDeclaration.accept(builder); 7343 constructorDeclaration.accept(builder);
7452 List<ConstructorElement> constructors = holder.constructors; 7344 List<ConstructorElement> constructors = holder.constructors;
7453 EngineTestCase.assertLength(1, constructors); 7345 EngineTestCase.assertLength(1, constructors);
7454 ConstructorElement constructor = constructors[0]; 7346 ConstructorElement constructor = constructors[0];
7455 JUnitTestCase.assertNotNull(constructor); 7347 expect(constructor, isNotNull);
7456 JUnitTestCase.assertFalse(constructor.isFactory); 7348 expect(constructor.isFactory, isFalse);
7457 JUnitTestCase.assertEquals("", constructor.name); 7349 expect(constructor.name, "");
7458 EngineTestCase.assertLength(0, constructor.functions); 7350 EngineTestCase.assertLength(0, constructor.functions);
7459 EngineTestCase.assertLength(0, constructor.labels); 7351 EngineTestCase.assertLength(0, constructor.labels);
7460 EngineTestCase.assertLength(0, constructor.localVariables); 7352 EngineTestCase.assertLength(0, constructor.localVariables);
7461 EngineTestCase.assertLength(0, constructor.parameters); 7353 EngineTestCase.assertLength(0, constructor.parameters);
7462 } 7354 }
7463 7355
7464 void test_visitConstructorDeclaration_named() { 7356 void test_visitConstructorDeclaration_named() {
7465 ElementHolder holder = new ElementHolder(); 7357 ElementHolder holder = new ElementHolder();
7466 ElementBuilder builder = new ElementBuilder(holder); 7358 ElementBuilder builder = new ElementBuilder(holder);
7467 String className = "A"; 7359 String className = "A";
7468 String constructorName = "c"; 7360 String constructorName = "c";
7469 ConstructorDeclaration constructorDeclaration = 7361 ConstructorDeclaration constructorDeclaration =
7470 AstFactory.constructorDeclaration2( 7362 AstFactory.constructorDeclaration2(
7471 null, 7363 null,
7472 null, 7364 null,
7473 AstFactory.identifier3(className), 7365 AstFactory.identifier3(className),
7474 constructorName, 7366 constructorName,
7475 AstFactory.formalParameterList([]), 7367 AstFactory.formalParameterList([]),
7476 null, 7368 null,
7477 AstFactory.blockFunctionBody2([])); 7369 AstFactory.blockFunctionBody2([]));
7478 constructorDeclaration.accept(builder); 7370 constructorDeclaration.accept(builder);
7479 List<ConstructorElement> constructors = holder.constructors; 7371 List<ConstructorElement> constructors = holder.constructors;
7480 EngineTestCase.assertLength(1, constructors); 7372 EngineTestCase.assertLength(1, constructors);
7481 ConstructorElement constructor = constructors[0]; 7373 ConstructorElement constructor = constructors[0];
7482 JUnitTestCase.assertNotNull(constructor); 7374 expect(constructor, isNotNull);
7483 JUnitTestCase.assertFalse(constructor.isFactory); 7375 expect(constructor.isFactory, isFalse);
7484 JUnitTestCase.assertEquals(constructorName, constructor.name); 7376 expect(constructor.name, constructorName);
7485 EngineTestCase.assertLength(0, constructor.functions); 7377 EngineTestCase.assertLength(0, constructor.functions);
7486 EngineTestCase.assertLength(0, constructor.labels); 7378 EngineTestCase.assertLength(0, constructor.labels);
7487 EngineTestCase.assertLength(0, constructor.localVariables); 7379 EngineTestCase.assertLength(0, constructor.localVariables);
7488 EngineTestCase.assertLength(0, constructor.parameters); 7380 EngineTestCase.assertLength(0, constructor.parameters);
7489 JUnitTestCase.assertSame( 7381 expect(constructorDeclaration.name.staticElement, same(constructor));
7490 constructor, 7382 expect(constructorDeclaration.element, same(constructor));
7491 constructorDeclaration.name.staticElement);
7492 JUnitTestCase.assertSame(constructor, constructorDeclaration.element);
7493 } 7383 }
7494 7384
7495 void test_visitConstructorDeclaration_unnamed() { 7385 void test_visitConstructorDeclaration_unnamed() {
7496 ElementHolder holder = new ElementHolder(); 7386 ElementHolder holder = new ElementHolder();
7497 ElementBuilder builder = new ElementBuilder(holder); 7387 ElementBuilder builder = new ElementBuilder(holder);
7498 String className = "A"; 7388 String className = "A";
7499 ConstructorDeclaration constructorDeclaration = 7389 ConstructorDeclaration constructorDeclaration =
7500 AstFactory.constructorDeclaration2( 7390 AstFactory.constructorDeclaration2(
7501 null, 7391 null,
7502 null, 7392 null,
7503 AstFactory.identifier3(className), 7393 AstFactory.identifier3(className),
7504 null, 7394 null,
7505 AstFactory.formalParameterList([]), 7395 AstFactory.formalParameterList([]),
7506 null, 7396 null,
7507 AstFactory.blockFunctionBody2([])); 7397 AstFactory.blockFunctionBody2([]));
7508 constructorDeclaration.accept(builder); 7398 constructorDeclaration.accept(builder);
7509 List<ConstructorElement> constructors = holder.constructors; 7399 List<ConstructorElement> constructors = holder.constructors;
7510 EngineTestCase.assertLength(1, constructors); 7400 EngineTestCase.assertLength(1, constructors);
7511 ConstructorElement constructor = constructors[0]; 7401 ConstructorElement constructor = constructors[0];
7512 JUnitTestCase.assertNotNull(constructor); 7402 expect(constructor, isNotNull);
7513 JUnitTestCase.assertFalse(constructor.isFactory); 7403 expect(constructor.isFactory, isFalse);
7514 JUnitTestCase.assertEquals("", constructor.name); 7404 expect(constructor.name, "");
7515 EngineTestCase.assertLength(0, constructor.functions); 7405 EngineTestCase.assertLength(0, constructor.functions);
7516 EngineTestCase.assertLength(0, constructor.labels); 7406 EngineTestCase.assertLength(0, constructor.labels);
7517 EngineTestCase.assertLength(0, constructor.localVariables); 7407 EngineTestCase.assertLength(0, constructor.localVariables);
7518 EngineTestCase.assertLength(0, constructor.parameters); 7408 EngineTestCase.assertLength(0, constructor.parameters);
7519 JUnitTestCase.assertSame(constructor, constructorDeclaration.element); 7409 expect(constructorDeclaration.element, same(constructor));
7520 } 7410 }
7521 7411
7522 void test_visitEnumDeclaration() { 7412 void test_visitEnumDeclaration() {
7523 ElementHolder holder = new ElementHolder(); 7413 ElementHolder holder = new ElementHolder();
7524 ElementBuilder builder = new ElementBuilder(holder); 7414 ElementBuilder builder = new ElementBuilder(holder);
7525 String enumName = "E"; 7415 String enumName = "E";
7526 EnumDeclaration enumDeclaration = 7416 EnumDeclaration enumDeclaration =
7527 AstFactory.enumDeclaration2(enumName, ["ONE"]); 7417 AstFactory.enumDeclaration2(enumName, ["ONE"]);
7528 enumDeclaration.accept(builder); 7418 enumDeclaration.accept(builder);
7529 List<ClassElement> enums = holder.enums; 7419 List<ClassElement> enums = holder.enums;
7530 EngineTestCase.assertLength(1, enums); 7420 EngineTestCase.assertLength(1, enums);
7531 ClassElement enumElement = enums[0]; 7421 ClassElement enumElement = enums[0];
7532 JUnitTestCase.assertNotNull(enumElement); 7422 expect(enumElement, isNotNull);
7533 JUnitTestCase.assertEquals(enumName, enumElement.name); 7423 expect(enumElement.name, enumName);
7534 } 7424 }
7535 7425
7536 void test_visitFieldDeclaration() { 7426 void test_visitFieldDeclaration() {
7537 ElementHolder holder = new ElementHolder(); 7427 ElementHolder holder = new ElementHolder();
7538 ElementBuilder builder = new ElementBuilder(holder); 7428 ElementBuilder builder = new ElementBuilder(holder);
7539 String firstFieldName = "x"; 7429 String firstFieldName = "x";
7540 String secondFieldName = "y"; 7430 String secondFieldName = "y";
7541 FieldDeclaration fieldDeclaration = AstFactory.fieldDeclaration2( 7431 FieldDeclaration fieldDeclaration = AstFactory.fieldDeclaration2(
7542 false, 7432 false,
7543 null, 7433 null,
7544 [ 7434 [
7545 AstFactory.variableDeclaration(firstFieldName), 7435 AstFactory.variableDeclaration(firstFieldName),
7546 AstFactory.variableDeclaration(secondFieldName)]); 7436 AstFactory.variableDeclaration(secondFieldName)]);
7547 fieldDeclaration.accept(builder); 7437 fieldDeclaration.accept(builder);
7548 List<FieldElement> fields = holder.fields; 7438 List<FieldElement> fields = holder.fields;
7549 EngineTestCase.assertLength(2, fields); 7439 EngineTestCase.assertLength(2, fields);
7550 FieldElement firstField = fields[0]; 7440 FieldElement firstField = fields[0];
7551 JUnitTestCase.assertNotNull(firstField); 7441 expect(firstField, isNotNull);
7552 JUnitTestCase.assertEquals(firstFieldName, firstField.name); 7442 expect(firstField.name, firstFieldName);
7553 JUnitTestCase.assertNull(firstField.initializer); 7443 expect(firstField.initializer, isNull);
7554 JUnitTestCase.assertFalse(firstField.isConst); 7444 expect(firstField.isConst, isFalse);
7555 JUnitTestCase.assertFalse(firstField.isFinal); 7445 expect(firstField.isFinal, isFalse);
7556 JUnitTestCase.assertFalse(firstField.isSynthetic); 7446 expect(firstField.isSynthetic, isFalse);
7557 FieldElement secondField = fields[1]; 7447 FieldElement secondField = fields[1];
7558 JUnitTestCase.assertNotNull(secondField); 7448 expect(secondField, isNotNull);
7559 JUnitTestCase.assertEquals(secondFieldName, secondField.name); 7449 expect(secondField.name, secondFieldName);
7560 JUnitTestCase.assertNull(secondField.initializer); 7450 expect(secondField.initializer, isNull);
7561 JUnitTestCase.assertFalse(secondField.isConst); 7451 expect(secondField.isConst, isFalse);
7562 JUnitTestCase.assertFalse(secondField.isFinal); 7452 expect(secondField.isFinal, isFalse);
7563 JUnitTestCase.assertFalse(secondField.isSynthetic); 7453 expect(secondField.isSynthetic, isFalse);
7564 } 7454 }
7565 7455
7566 void test_visitFieldFormalParameter() { 7456 void test_visitFieldFormalParameter() {
7567 ElementHolder holder = new ElementHolder(); 7457 ElementHolder holder = new ElementHolder();
7568 ElementBuilder builder = new ElementBuilder(holder); 7458 ElementBuilder builder = new ElementBuilder(holder);
7569 String parameterName = "p"; 7459 String parameterName = "p";
7570 FieldFormalParameter formalParameter = 7460 FieldFormalParameter formalParameter =
7571 AstFactory.fieldFormalParameter(null, null, parameterName); 7461 AstFactory.fieldFormalParameter(null, null, parameterName);
7572 formalParameter.accept(builder); 7462 formalParameter.accept(builder);
7573 List<ParameterElement> parameters = holder.parameters; 7463 List<ParameterElement> parameters = holder.parameters;
7574 EngineTestCase.assertLength(1, parameters); 7464 EngineTestCase.assertLength(1, parameters);
7575 ParameterElement parameter = parameters[0]; 7465 ParameterElement parameter = parameters[0];
7576 JUnitTestCase.assertNotNull(parameter); 7466 expect(parameter, isNotNull);
7577 JUnitTestCase.assertEquals(parameterName, parameter.name); 7467 expect(parameter.name, parameterName);
7578 JUnitTestCase.assertNull(parameter.initializer); 7468 expect(parameter.initializer, isNull);
7579 JUnitTestCase.assertFalse(parameter.isConst); 7469 expect(parameter.isConst, isFalse);
7580 JUnitTestCase.assertFalse(parameter.isFinal); 7470 expect(parameter.isFinal, isFalse);
7581 JUnitTestCase.assertFalse(parameter.isSynthetic); 7471 expect(parameter.isSynthetic, isFalse);
7582 JUnitTestCase.assertEquals(ParameterKind.REQUIRED, parameter.parameterKind); 7472 expect(parameter.parameterKind, ParameterKind.REQUIRED);
7583 EngineTestCase.assertLength(0, parameter.parameters); 7473 EngineTestCase.assertLength(0, parameter.parameters);
7584 } 7474 }
7585 7475
7586 void test_visitFieldFormalParameter_funtionTyped() { 7476 void test_visitFieldFormalParameter_funtionTyped() {
7587 ElementHolder holder = new ElementHolder(); 7477 ElementHolder holder = new ElementHolder();
7588 ElementBuilder builder = new ElementBuilder(holder); 7478 ElementBuilder builder = new ElementBuilder(holder);
7589 String parameterName = "p"; 7479 String parameterName = "p";
7590 FieldFormalParameter formalParameter = AstFactory.fieldFormalParameter( 7480 FieldFormalParameter formalParameter = AstFactory.fieldFormalParameter(
7591 null, 7481 null,
7592 null, 7482 null,
7593 parameterName, 7483 parameterName,
7594 AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("a")]) ); 7484 AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("a")]) );
7595 formalParameter.accept(builder); 7485 formalParameter.accept(builder);
7596 List<ParameterElement> parameters = holder.parameters; 7486 List<ParameterElement> parameters = holder.parameters;
7597 EngineTestCase.assertLength(1, parameters); 7487 EngineTestCase.assertLength(1, parameters);
7598 ParameterElement parameter = parameters[0]; 7488 ParameterElement parameter = parameters[0];
7599 JUnitTestCase.assertNotNull(parameter); 7489 expect(parameter, isNotNull);
7600 JUnitTestCase.assertEquals(parameterName, parameter.name); 7490 expect(parameter.name, parameterName);
7601 JUnitTestCase.assertNull(parameter.initializer); 7491 expect(parameter.initializer, isNull);
7602 JUnitTestCase.assertFalse(parameter.isConst); 7492 expect(parameter.isConst, isFalse);
7603 JUnitTestCase.assertFalse(parameter.isFinal); 7493 expect(parameter.isFinal, isFalse);
7604 JUnitTestCase.assertFalse(parameter.isSynthetic); 7494 expect(parameter.isSynthetic, isFalse);
7605 JUnitTestCase.assertEquals(ParameterKind.REQUIRED, parameter.parameterKind); 7495 expect(parameter.parameterKind, ParameterKind.REQUIRED);
7606 EngineTestCase.assertLength(1, parameter.parameters); 7496 EngineTestCase.assertLength(1, parameter.parameters);
7607 } 7497 }
7608 7498
7609 void test_visitFormalParameterList() { 7499 void test_visitFormalParameterList() {
7610 ElementHolder holder = new ElementHolder(); 7500 ElementHolder holder = new ElementHolder();
7611 ElementBuilder builder = new ElementBuilder(holder); 7501 ElementBuilder builder = new ElementBuilder(holder);
7612 String firstParameterName = "a"; 7502 String firstParameterName = "a";
7613 String secondParameterName = "b"; 7503 String secondParameterName = "b";
7614 FormalParameterList parameterList = AstFactory.formalParameterList( 7504 FormalParameterList parameterList = AstFactory.formalParameterList(
7615 [ 7505 [
7616 AstFactory.simpleFormalParameter3(firstParameterName), 7506 AstFactory.simpleFormalParameter3(firstParameterName),
7617 AstFactory.simpleFormalParameter3(secondParameterName)]); 7507 AstFactory.simpleFormalParameter3(secondParameterName)]);
7618 parameterList.accept(builder); 7508 parameterList.accept(builder);
7619 List<ParameterElement> parameters = holder.parameters; 7509 List<ParameterElement> parameters = holder.parameters;
7620 EngineTestCase.assertLength(2, parameters); 7510 EngineTestCase.assertLength(2, parameters);
7621 JUnitTestCase.assertEquals(firstParameterName, parameters[0].name); 7511 expect(parameters[0].name, firstParameterName);
7622 JUnitTestCase.assertEquals(secondParameterName, parameters[1].name); 7512 expect(parameters[1].name, secondParameterName);
7623 } 7513 }
7624 7514
7625 void test_visitFunctionDeclaration_getter() { 7515 void test_visitFunctionDeclaration_getter() {
7626 ElementHolder holder = new ElementHolder(); 7516 ElementHolder holder = new ElementHolder();
7627 ElementBuilder builder = new ElementBuilder(holder); 7517 ElementBuilder builder = new ElementBuilder(holder);
7628 String functionName = "f"; 7518 String functionName = "f";
7629 FunctionDeclaration declaration = AstFactory.functionDeclaration( 7519 FunctionDeclaration declaration = AstFactory.functionDeclaration(
7630 null, 7520 null,
7631 Keyword.GET, 7521 Keyword.GET,
7632 functionName, 7522 functionName,
7633 AstFactory.functionExpression2( 7523 AstFactory.functionExpression2(
7634 AstFactory.formalParameterList([]), 7524 AstFactory.formalParameterList([]),
7635 AstFactory.blockFunctionBody2([]))); 7525 AstFactory.blockFunctionBody2([])));
7636 declaration.accept(builder); 7526 declaration.accept(builder);
7637 List<PropertyAccessorElement> accessors = holder.accessors; 7527 List<PropertyAccessorElement> accessors = holder.accessors;
7638 EngineTestCase.assertLength(1, accessors); 7528 EngineTestCase.assertLength(1, accessors);
7639 PropertyAccessorElement accessor = accessors[0]; 7529 PropertyAccessorElement accessor = accessors[0];
7640 JUnitTestCase.assertNotNull(accessor); 7530 expect(accessor, isNotNull);
7641 JUnitTestCase.assertEquals(functionName, accessor.name); 7531 expect(accessor.name, functionName);
7642 JUnitTestCase.assertSame(accessor, declaration.element); 7532 expect(declaration.element, same(accessor));
7643 JUnitTestCase.assertSame(accessor, declaration.functionExpression.element); 7533 expect(declaration.functionExpression.element, same(accessor));
7644 JUnitTestCase.assertTrue(accessor.isGetter); 7534 expect(accessor.isGetter, isTrue);
7645 JUnitTestCase.assertFalse(accessor.isSetter); 7535 expect(accessor.isSetter, isFalse);
7646 JUnitTestCase.assertFalse(accessor.isSynthetic); 7536 expect(accessor.isSynthetic, isFalse);
7647 PropertyInducingElement variable = accessor.variable; 7537 PropertyInducingElement variable = accessor.variable;
7648 EngineTestCase.assertInstanceOf( 7538 EngineTestCase.assertInstanceOf(
7649 (obj) => obj is TopLevelVariableElement, 7539 (obj) => obj is TopLevelVariableElement,
7650 TopLevelVariableElement, 7540 TopLevelVariableElement,
7651 variable); 7541 variable);
7652 JUnitTestCase.assertTrue(variable.isSynthetic); 7542 expect(variable.isSynthetic, isTrue);
7653 } 7543 }
7654 7544
7655 void test_visitFunctionDeclaration_plain() { 7545 void test_visitFunctionDeclaration_plain() {
7656 ElementHolder holder = new ElementHolder(); 7546 ElementHolder holder = new ElementHolder();
7657 ElementBuilder builder = new ElementBuilder(holder); 7547 ElementBuilder builder = new ElementBuilder(holder);
7658 String functionName = "f"; 7548 String functionName = "f";
7659 FunctionDeclaration declaration = AstFactory.functionDeclaration( 7549 FunctionDeclaration declaration = AstFactory.functionDeclaration(
7660 null, 7550 null,
7661 null, 7551 null,
7662 functionName, 7552 functionName,
7663 AstFactory.functionExpression2( 7553 AstFactory.functionExpression2(
7664 AstFactory.formalParameterList([]), 7554 AstFactory.formalParameterList([]),
7665 AstFactory.blockFunctionBody2([]))); 7555 AstFactory.blockFunctionBody2([])));
7666 declaration.accept(builder); 7556 declaration.accept(builder);
7667 List<FunctionElement> functions = holder.functions; 7557 List<FunctionElement> functions = holder.functions;
7668 EngineTestCase.assertLength(1, functions); 7558 EngineTestCase.assertLength(1, functions);
7669 FunctionElement function = functions[0]; 7559 FunctionElement function = functions[0];
7670 JUnitTestCase.assertNotNull(function); 7560 expect(function, isNotNull);
7671 JUnitTestCase.assertEquals(functionName, function.name); 7561 expect(function.name, functionName);
7672 JUnitTestCase.assertSame(function, declaration.element); 7562 expect(declaration.element, same(function));
7673 JUnitTestCase.assertSame(function, declaration.functionExpression.element); 7563 expect(declaration.functionExpression.element, same(function));
7674 JUnitTestCase.assertFalse(function.isSynthetic); 7564 expect(function.isSynthetic, isFalse);
7675 } 7565 }
7676 7566
7677 void test_visitFunctionDeclaration_setter() { 7567 void test_visitFunctionDeclaration_setter() {
7678 ElementHolder holder = new ElementHolder(); 7568 ElementHolder holder = new ElementHolder();
7679 ElementBuilder builder = new ElementBuilder(holder); 7569 ElementBuilder builder = new ElementBuilder(holder);
7680 String functionName = "f"; 7570 String functionName = "f";
7681 FunctionDeclaration declaration = AstFactory.functionDeclaration( 7571 FunctionDeclaration declaration = AstFactory.functionDeclaration(
7682 null, 7572 null,
7683 Keyword.SET, 7573 Keyword.SET,
7684 functionName, 7574 functionName,
7685 AstFactory.functionExpression2( 7575 AstFactory.functionExpression2(
7686 AstFactory.formalParameterList([]), 7576 AstFactory.formalParameterList([]),
7687 AstFactory.blockFunctionBody2([]))); 7577 AstFactory.blockFunctionBody2([])));
7688 declaration.accept(builder); 7578 declaration.accept(builder);
7689 List<PropertyAccessorElement> accessors = holder.accessors; 7579 List<PropertyAccessorElement> accessors = holder.accessors;
7690 EngineTestCase.assertLength(1, accessors); 7580 EngineTestCase.assertLength(1, accessors);
7691 PropertyAccessorElement accessor = accessors[0]; 7581 PropertyAccessorElement accessor = accessors[0];
7692 JUnitTestCase.assertNotNull(accessor); 7582 expect(accessor, isNotNull);
7693 JUnitTestCase.assertEquals("$functionName=", accessor.name); 7583 expect(accessor.name, "$functionName=");
7694 JUnitTestCase.assertSame(accessor, declaration.element); 7584 expect(declaration.element, same(accessor));
7695 JUnitTestCase.assertSame(accessor, declaration.functionExpression.element); 7585 expect(declaration.functionExpression.element, same(accessor));
7696 JUnitTestCase.assertFalse(accessor.isGetter); 7586 expect(accessor.isGetter, isFalse);
7697 JUnitTestCase.assertTrue(accessor.isSetter); 7587 expect(accessor.isSetter, isTrue);
7698 JUnitTestCase.assertFalse(accessor.isSynthetic); 7588 expect(accessor.isSynthetic, isFalse);
7699 PropertyInducingElement variable = accessor.variable; 7589 PropertyInducingElement variable = accessor.variable;
7700 EngineTestCase.assertInstanceOf( 7590 EngineTestCase.assertInstanceOf(
7701 (obj) => obj is TopLevelVariableElement, 7591 (obj) => obj is TopLevelVariableElement,
7702 TopLevelVariableElement, 7592 TopLevelVariableElement,
7703 variable); 7593 variable);
7704 JUnitTestCase.assertTrue(variable.isSynthetic); 7594 expect(variable.isSynthetic, isTrue);
7705 } 7595 }
7706 7596
7707 void test_visitFunctionExpression() { 7597 void test_visitFunctionExpression() {
7708 ElementHolder holder = new ElementHolder(); 7598 ElementHolder holder = new ElementHolder();
7709 ElementBuilder builder = new ElementBuilder(holder); 7599 ElementBuilder builder = new ElementBuilder(holder);
7710 FunctionExpression expression = AstFactory.functionExpression2( 7600 FunctionExpression expression = AstFactory.functionExpression2(
7711 AstFactory.formalParameterList([]), 7601 AstFactory.formalParameterList([]),
7712 AstFactory.blockFunctionBody2([])); 7602 AstFactory.blockFunctionBody2([]));
7713 expression.accept(builder); 7603 expression.accept(builder);
7714 List<FunctionElement> functions = holder.functions; 7604 List<FunctionElement> functions = holder.functions;
7715 EngineTestCase.assertLength(1, functions); 7605 EngineTestCase.assertLength(1, functions);
7716 FunctionElement function = functions[0]; 7606 FunctionElement function = functions[0];
7717 JUnitTestCase.assertNotNull(function); 7607 expect(function, isNotNull);
7718 JUnitTestCase.assertSame(function, expression.element); 7608 expect(expression.element, same(function));
7719 JUnitTestCase.assertFalse(function.isSynthetic); 7609 expect(function.isSynthetic, isFalse);
7720 } 7610 }
7721 7611
7722 void test_visitFunctionTypeAlias() { 7612 void test_visitFunctionTypeAlias() {
7723 ElementHolder holder = new ElementHolder(); 7613 ElementHolder holder = new ElementHolder();
7724 ElementBuilder builder = new ElementBuilder(holder); 7614 ElementBuilder builder = new ElementBuilder(holder);
7725 String aliasName = "F"; 7615 String aliasName = "F";
7726 String parameterName = "E"; 7616 String parameterName = "E";
7727 FunctionTypeAlias aliasNode = AstFactory.typeAlias( 7617 FunctionTypeAlias aliasNode = AstFactory.typeAlias(
7728 null, 7618 null,
7729 aliasName, 7619 aliasName,
7730 AstFactory.typeParameterList([parameterName]), 7620 AstFactory.typeParameterList([parameterName]),
7731 null); 7621 null);
7732 aliasNode.accept(builder); 7622 aliasNode.accept(builder);
7733 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 7623 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
7734 EngineTestCase.assertLength(1, aliases); 7624 EngineTestCase.assertLength(1, aliases);
7735 FunctionTypeAliasElement alias = aliases[0]; 7625 FunctionTypeAliasElement alias = aliases[0];
7736 JUnitTestCase.assertNotNull(alias); 7626 expect(alias, isNotNull);
7737 JUnitTestCase.assertEquals(aliasName, alias.name); 7627 expect(alias.name, aliasName);
7738 EngineTestCase.assertLength(0, alias.parameters); 7628 EngineTestCase.assertLength(0, alias.parameters);
7739 List<TypeParameterElement> typeParameters = alias.typeParameters; 7629 List<TypeParameterElement> typeParameters = alias.typeParameters;
7740 EngineTestCase.assertLength(1, typeParameters); 7630 EngineTestCase.assertLength(1, typeParameters);
7741 TypeParameterElement typeParameter = typeParameters[0]; 7631 TypeParameterElement typeParameter = typeParameters[0];
7742 JUnitTestCase.assertNotNull(typeParameter); 7632 expect(typeParameter, isNotNull);
7743 JUnitTestCase.assertEquals(parameterName, typeParameter.name); 7633 expect(typeParameter.name, parameterName);
7744 } 7634 }
7745 7635
7746 void test_visitFunctionTypedFormalParameter() { 7636 void test_visitFunctionTypedFormalParameter() {
7747 ElementHolder holder = new ElementHolder(); 7637 ElementHolder holder = new ElementHolder();
7748 ElementBuilder builder = new ElementBuilder(holder); 7638 ElementBuilder builder = new ElementBuilder(holder);
7749 String parameterName = "p"; 7639 String parameterName = "p";
7750 FunctionTypedFormalParameter formalParameter = 7640 FunctionTypedFormalParameter formalParameter =
7751 AstFactory.functionTypedFormalParameter(null, parameterName, []); 7641 AstFactory.functionTypedFormalParameter(null, parameterName, []);
7752 _useParameterInMethod(formalParameter, 100, 110); 7642 _useParameterInMethod(formalParameter, 100, 110);
7753 formalParameter.accept(builder); 7643 formalParameter.accept(builder);
7754 List<ParameterElement> parameters = holder.parameters; 7644 List<ParameterElement> parameters = holder.parameters;
7755 EngineTestCase.assertLength(1, parameters); 7645 EngineTestCase.assertLength(1, parameters);
7756 ParameterElement parameter = parameters[0]; 7646 ParameterElement parameter = parameters[0];
7757 JUnitTestCase.assertNotNull(parameter); 7647 expect(parameter, isNotNull);
7758 JUnitTestCase.assertEquals(parameterName, parameter.name); 7648 expect(parameter.name, parameterName);
7759 JUnitTestCase.assertNull(parameter.initializer); 7649 expect(parameter.initializer, isNull);
7760 JUnitTestCase.assertFalse(parameter.isConst); 7650 expect(parameter.isConst, isFalse);
7761 JUnitTestCase.assertFalse(parameter.isFinal); 7651 expect(parameter.isFinal, isFalse);
7762 JUnitTestCase.assertFalse(parameter.isSynthetic); 7652 expect(parameter.isSynthetic, isFalse);
7763 JUnitTestCase.assertEquals(ParameterKind.REQUIRED, parameter.parameterKind); 7653 expect(parameter.parameterKind, ParameterKind.REQUIRED);
7764 { 7654 {
7765 SourceRange visibleRange = parameter.visibleRange; 7655 SourceRange visibleRange = parameter.visibleRange;
7766 JUnitTestCase.assertEquals(visibleRange.offset, 100); 7656 expect(100, visibleRange.offset);
7767 JUnitTestCase.assertEquals(visibleRange.end, 110); 7657 expect(110, visibleRange.end);
7768 } 7658 }
7769 } 7659 }
7770 7660
7771 void test_visitLabeledStatement() { 7661 void test_visitLabeledStatement() {
7772 ElementHolder holder = new ElementHolder(); 7662 ElementHolder holder = new ElementHolder();
7773 ElementBuilder builder = new ElementBuilder(holder); 7663 ElementBuilder builder = new ElementBuilder(holder);
7774 String labelName = "l"; 7664 String labelName = "l";
7775 LabeledStatement statement = AstFactory.labeledStatement( 7665 LabeledStatement statement = AstFactory.labeledStatement(
7776 AstFactory.list([AstFactory.label2(labelName)]), 7666 AstFactory.list([AstFactory.label2(labelName)]),
7777 AstFactory.breakStatement()); 7667 AstFactory.breakStatement());
7778 statement.accept(builder); 7668 statement.accept(builder);
7779 List<LabelElement> labels = holder.labels; 7669 List<LabelElement> labels = holder.labels;
7780 EngineTestCase.assertLength(1, labels); 7670 EngineTestCase.assertLength(1, labels);
7781 LabelElement label = labels[0]; 7671 LabelElement label = labels[0];
7782 JUnitTestCase.assertNotNull(label); 7672 expect(label, isNotNull);
7783 JUnitTestCase.assertEquals(labelName, label.name); 7673 expect(label.name, labelName);
7784 JUnitTestCase.assertFalse(label.isSynthetic); 7674 expect(label.isSynthetic, isFalse);
7785 } 7675 }
7786 7676
7787 void test_visitMethodDeclaration_abstract() { 7677 void test_visitMethodDeclaration_abstract() {
7788 ElementHolder holder = new ElementHolder(); 7678 ElementHolder holder = new ElementHolder();
7789 ElementBuilder builder = new ElementBuilder(holder); 7679 ElementBuilder builder = new ElementBuilder(holder);
7790 String methodName = "m"; 7680 String methodName = "m";
7791 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7681 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7792 null, 7682 null,
7793 null, 7683 null,
7794 null, 7684 null,
7795 null, 7685 null,
7796 AstFactory.identifier3(methodName), 7686 AstFactory.identifier3(methodName),
7797 AstFactory.formalParameterList([]), 7687 AstFactory.formalParameterList([]),
7798 AstFactory.emptyFunctionBody()); 7688 AstFactory.emptyFunctionBody());
7799 methodDeclaration.accept(builder); 7689 methodDeclaration.accept(builder);
7800 List<MethodElement> methods = holder.methods; 7690 List<MethodElement> methods = holder.methods;
7801 EngineTestCase.assertLength(1, methods); 7691 EngineTestCase.assertLength(1, methods);
7802 MethodElement method = methods[0]; 7692 MethodElement method = methods[0];
7803 JUnitTestCase.assertNotNull(method); 7693 expect(method, isNotNull);
7804 JUnitTestCase.assertEquals(methodName, method.name); 7694 expect(method.name, methodName);
7805 EngineTestCase.assertLength(0, method.functions); 7695 EngineTestCase.assertLength(0, method.functions);
7806 EngineTestCase.assertLength(0, method.labels); 7696 EngineTestCase.assertLength(0, method.labels);
7807 EngineTestCase.assertLength(0, method.localVariables); 7697 EngineTestCase.assertLength(0, method.localVariables);
7808 EngineTestCase.assertLength(0, method.parameters); 7698 EngineTestCase.assertLength(0, method.parameters);
7809 JUnitTestCase.assertTrue(method.isAbstract); 7699 expect(method.isAbstract, isTrue);
7810 JUnitTestCase.assertFalse(method.isStatic); 7700 expect(method.isStatic, isFalse);
7811 JUnitTestCase.assertFalse(method.isSynthetic); 7701 expect(method.isSynthetic, isFalse);
7812 } 7702 }
7813 7703
7814 void test_visitMethodDeclaration_getter() { 7704 void test_visitMethodDeclaration_getter() {
7815 ElementHolder holder = new ElementHolder(); 7705 ElementHolder holder = new ElementHolder();
7816 ElementBuilder builder = new ElementBuilder(holder); 7706 ElementBuilder builder = new ElementBuilder(holder);
7817 String methodName = "m"; 7707 String methodName = "m";
7818 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7708 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7819 null, 7709 null,
7820 null, 7710 null,
7821 Keyword.GET, 7711 Keyword.GET,
7822 null, 7712 null,
7823 AstFactory.identifier3(methodName), 7713 AstFactory.identifier3(methodName),
7824 AstFactory.formalParameterList([]), 7714 AstFactory.formalParameterList([]),
7825 AstFactory.blockFunctionBody2([])); 7715 AstFactory.blockFunctionBody2([]));
7826 methodDeclaration.accept(builder); 7716 methodDeclaration.accept(builder);
7827 List<FieldElement> fields = holder.fields; 7717 List<FieldElement> fields = holder.fields;
7828 EngineTestCase.assertLength(1, fields); 7718 EngineTestCase.assertLength(1, fields);
7829 FieldElement field = fields[0]; 7719 FieldElement field = fields[0];
7830 JUnitTestCase.assertNotNull(field); 7720 expect(field, isNotNull);
7831 JUnitTestCase.assertEquals(methodName, field.name); 7721 expect(field.name, methodName);
7832 JUnitTestCase.assertTrue(field.isSynthetic); 7722 expect(field.isSynthetic, isTrue);
7833 JUnitTestCase.assertNull(field.setter); 7723 expect(field.setter, isNull);
7834 PropertyAccessorElement getter = field.getter; 7724 PropertyAccessorElement getter = field.getter;
7835 JUnitTestCase.assertNotNull(getter); 7725 expect(getter, isNotNull);
7836 JUnitTestCase.assertFalse(getter.isAbstract); 7726 expect(getter.isAbstract, isFalse);
7837 JUnitTestCase.assertTrue(getter.isGetter); 7727 expect(getter.isGetter, isTrue);
7838 JUnitTestCase.assertFalse(getter.isSynthetic); 7728 expect(getter.isSynthetic, isFalse);
7839 JUnitTestCase.assertEquals(methodName, getter.name); 7729 expect(getter.name, methodName);
7840 JUnitTestCase.assertEquals(field, getter.variable); 7730 expect(getter.variable, field);
7841 EngineTestCase.assertLength(0, getter.functions); 7731 EngineTestCase.assertLength(0, getter.functions);
7842 EngineTestCase.assertLength(0, getter.labels); 7732 EngineTestCase.assertLength(0, getter.labels);
7843 EngineTestCase.assertLength(0, getter.localVariables); 7733 EngineTestCase.assertLength(0, getter.localVariables);
7844 EngineTestCase.assertLength(0, getter.parameters); 7734 EngineTestCase.assertLength(0, getter.parameters);
7845 } 7735 }
7846 7736
7847 void test_visitMethodDeclaration_getter_abstract() { 7737 void test_visitMethodDeclaration_getter_abstract() {
7848 ElementHolder holder = new ElementHolder(); 7738 ElementHolder holder = new ElementHolder();
7849 ElementBuilder builder = new ElementBuilder(holder); 7739 ElementBuilder builder = new ElementBuilder(holder);
7850 String methodName = "m"; 7740 String methodName = "m";
7851 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7741 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7852 null, 7742 null,
7853 null, 7743 null,
7854 Keyword.GET, 7744 Keyword.GET,
7855 null, 7745 null,
7856 AstFactory.identifier3(methodName), 7746 AstFactory.identifier3(methodName),
7857 AstFactory.formalParameterList([]), 7747 AstFactory.formalParameterList([]),
7858 AstFactory.emptyFunctionBody()); 7748 AstFactory.emptyFunctionBody());
7859 methodDeclaration.accept(builder); 7749 methodDeclaration.accept(builder);
7860 List<FieldElement> fields = holder.fields; 7750 List<FieldElement> fields = holder.fields;
7861 EngineTestCase.assertLength(1, fields); 7751 EngineTestCase.assertLength(1, fields);
7862 FieldElement field = fields[0]; 7752 FieldElement field = fields[0];
7863 JUnitTestCase.assertNotNull(field); 7753 expect(field, isNotNull);
7864 JUnitTestCase.assertEquals(methodName, field.name); 7754 expect(field.name, methodName);
7865 JUnitTestCase.assertTrue(field.isSynthetic); 7755 expect(field.isSynthetic, isTrue);
7866 JUnitTestCase.assertNull(field.setter); 7756 expect(field.setter, isNull);
7867 PropertyAccessorElement getter = field.getter; 7757 PropertyAccessorElement getter = field.getter;
7868 JUnitTestCase.assertNotNull(getter); 7758 expect(getter, isNotNull);
7869 JUnitTestCase.assertTrue(getter.isAbstract); 7759 expect(getter.isAbstract, isTrue);
7870 JUnitTestCase.assertTrue(getter.isGetter); 7760 expect(getter.isGetter, isTrue);
7871 JUnitTestCase.assertFalse(getter.isSynthetic); 7761 expect(getter.isSynthetic, isFalse);
7872 JUnitTestCase.assertEquals(methodName, getter.name); 7762 expect(getter.name, methodName);
7873 JUnitTestCase.assertEquals(field, getter.variable); 7763 expect(getter.variable, field);
7874 EngineTestCase.assertLength(0, getter.functions); 7764 EngineTestCase.assertLength(0, getter.functions);
7875 EngineTestCase.assertLength(0, getter.labels); 7765 EngineTestCase.assertLength(0, getter.labels);
7876 EngineTestCase.assertLength(0, getter.localVariables); 7766 EngineTestCase.assertLength(0, getter.localVariables);
7877 EngineTestCase.assertLength(0, getter.parameters); 7767 EngineTestCase.assertLength(0, getter.parameters);
7878 } 7768 }
7879 7769
7880 void test_visitMethodDeclaration_getter_external() { 7770 void test_visitMethodDeclaration_getter_external() {
7881 ElementHolder holder = new ElementHolder(); 7771 ElementHolder holder = new ElementHolder();
7882 ElementBuilder builder = new ElementBuilder(holder); 7772 ElementBuilder builder = new ElementBuilder(holder);
7883 String methodName = "m"; 7773 String methodName = "m";
7884 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration( 7774 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration(
7885 null, 7775 null,
7886 null, 7776 null,
7887 Keyword.GET, 7777 Keyword.GET,
7888 null, 7778 null,
7889 AstFactory.identifier3(methodName), 7779 AstFactory.identifier3(methodName),
7890 AstFactory.formalParameterList([])); 7780 AstFactory.formalParameterList([]));
7891 methodDeclaration.accept(builder); 7781 methodDeclaration.accept(builder);
7892 List<FieldElement> fields = holder.fields; 7782 List<FieldElement> fields = holder.fields;
7893 EngineTestCase.assertLength(1, fields); 7783 EngineTestCase.assertLength(1, fields);
7894 FieldElement field = fields[0]; 7784 FieldElement field = fields[0];
7895 JUnitTestCase.assertNotNull(field); 7785 expect(field, isNotNull);
7896 JUnitTestCase.assertEquals(methodName, field.name); 7786 expect(field.name, methodName);
7897 JUnitTestCase.assertTrue(field.isSynthetic); 7787 expect(field.isSynthetic, isTrue);
7898 JUnitTestCase.assertNull(field.setter); 7788 expect(field.setter, isNull);
7899 PropertyAccessorElement getter = field.getter; 7789 PropertyAccessorElement getter = field.getter;
7900 JUnitTestCase.assertNotNull(getter); 7790 expect(getter, isNotNull);
7901 JUnitTestCase.assertFalse(getter.isAbstract); 7791 expect(getter.isAbstract, isFalse);
7902 JUnitTestCase.assertTrue(getter.isGetter); 7792 expect(getter.isGetter, isTrue);
7903 JUnitTestCase.assertFalse(getter.isSynthetic); 7793 expect(getter.isSynthetic, isFalse);
7904 JUnitTestCase.assertEquals(methodName, getter.name); 7794 expect(getter.name, methodName);
7905 JUnitTestCase.assertEquals(field, getter.variable); 7795 expect(getter.variable, field);
7906 EngineTestCase.assertLength(0, getter.functions); 7796 EngineTestCase.assertLength(0, getter.functions);
7907 EngineTestCase.assertLength(0, getter.labels); 7797 EngineTestCase.assertLength(0, getter.labels);
7908 EngineTestCase.assertLength(0, getter.localVariables); 7798 EngineTestCase.assertLength(0, getter.localVariables);
7909 EngineTestCase.assertLength(0, getter.parameters); 7799 EngineTestCase.assertLength(0, getter.parameters);
7910 } 7800 }
7911 7801
7912 void test_visitMethodDeclaration_minimal() { 7802 void test_visitMethodDeclaration_minimal() {
7913 ElementHolder holder = new ElementHolder(); 7803 ElementHolder holder = new ElementHolder();
7914 ElementBuilder builder = new ElementBuilder(holder); 7804 ElementBuilder builder = new ElementBuilder(holder);
7915 String methodName = "m"; 7805 String methodName = "m";
7916 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7806 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7917 null, 7807 null,
7918 null, 7808 null,
7919 null, 7809 null,
7920 null, 7810 null,
7921 AstFactory.identifier3(methodName), 7811 AstFactory.identifier3(methodName),
7922 AstFactory.formalParameterList([]), 7812 AstFactory.formalParameterList([]),
7923 AstFactory.blockFunctionBody2([])); 7813 AstFactory.blockFunctionBody2([]));
7924 methodDeclaration.accept(builder); 7814 methodDeclaration.accept(builder);
7925 List<MethodElement> methods = holder.methods; 7815 List<MethodElement> methods = holder.methods;
7926 EngineTestCase.assertLength(1, methods); 7816 EngineTestCase.assertLength(1, methods);
7927 MethodElement method = methods[0]; 7817 MethodElement method = methods[0];
7928 JUnitTestCase.assertNotNull(method); 7818 expect(method, isNotNull);
7929 JUnitTestCase.assertEquals(methodName, method.name); 7819 expect(method.name, methodName);
7930 EngineTestCase.assertLength(0, method.functions); 7820 EngineTestCase.assertLength(0, method.functions);
7931 EngineTestCase.assertLength(0, method.labels); 7821 EngineTestCase.assertLength(0, method.labels);
7932 EngineTestCase.assertLength(0, method.localVariables); 7822 EngineTestCase.assertLength(0, method.localVariables);
7933 EngineTestCase.assertLength(0, method.parameters); 7823 EngineTestCase.assertLength(0, method.parameters);
7934 JUnitTestCase.assertFalse(method.isAbstract); 7824 expect(method.isAbstract, isFalse);
7935 JUnitTestCase.assertFalse(method.isStatic); 7825 expect(method.isStatic, isFalse);
7936 JUnitTestCase.assertFalse(method.isSynthetic); 7826 expect(method.isSynthetic, isFalse);
7937 } 7827 }
7938 7828
7939 void test_visitMethodDeclaration_operator() { 7829 void test_visitMethodDeclaration_operator() {
7940 ElementHolder holder = new ElementHolder(); 7830 ElementHolder holder = new ElementHolder();
7941 ElementBuilder builder = new ElementBuilder(holder); 7831 ElementBuilder builder = new ElementBuilder(holder);
7942 String methodName = "+"; 7832 String methodName = "+";
7943 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7833 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7944 null, 7834 null,
7945 null, 7835 null,
7946 null, 7836 null,
7947 Keyword.OPERATOR, 7837 Keyword.OPERATOR,
7948 AstFactory.identifier3(methodName), 7838 AstFactory.identifier3(methodName),
7949 AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("adden d")]), 7839 AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("adden d")]),
7950 AstFactory.blockFunctionBody2([])); 7840 AstFactory.blockFunctionBody2([]));
7951 methodDeclaration.accept(builder); 7841 methodDeclaration.accept(builder);
7952 List<MethodElement> methods = holder.methods; 7842 List<MethodElement> methods = holder.methods;
7953 EngineTestCase.assertLength(1, methods); 7843 EngineTestCase.assertLength(1, methods);
7954 MethodElement method = methods[0]; 7844 MethodElement method = methods[0];
7955 JUnitTestCase.assertNotNull(method); 7845 expect(method, isNotNull);
7956 JUnitTestCase.assertEquals(methodName, method.name); 7846 expect(method.name, methodName);
7957 EngineTestCase.assertLength(0, method.functions); 7847 EngineTestCase.assertLength(0, method.functions);
7958 EngineTestCase.assertLength(0, method.labels); 7848 EngineTestCase.assertLength(0, method.labels);
7959 EngineTestCase.assertLength(0, method.localVariables); 7849 EngineTestCase.assertLength(0, method.localVariables);
7960 EngineTestCase.assertLength(1, method.parameters); 7850 EngineTestCase.assertLength(1, method.parameters);
7961 JUnitTestCase.assertFalse(method.isAbstract); 7851 expect(method.isAbstract, isFalse);
7962 JUnitTestCase.assertFalse(method.isStatic); 7852 expect(method.isStatic, isFalse);
7963 JUnitTestCase.assertFalse(method.isSynthetic); 7853 expect(method.isSynthetic, isFalse);
7964 } 7854 }
7965 7855
7966 void test_visitMethodDeclaration_setter() { 7856 void test_visitMethodDeclaration_setter() {
7967 ElementHolder holder = new ElementHolder(); 7857 ElementHolder holder = new ElementHolder();
7968 ElementBuilder builder = new ElementBuilder(holder); 7858 ElementBuilder builder = new ElementBuilder(holder);
7969 String methodName = "m"; 7859 String methodName = "m";
7970 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7860 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7971 null, 7861 null,
7972 null, 7862 null,
7973 Keyword.SET, 7863 Keyword.SET,
7974 null, 7864 null,
7975 AstFactory.identifier3(methodName), 7865 AstFactory.identifier3(methodName),
7976 AstFactory.formalParameterList([]), 7866 AstFactory.formalParameterList([]),
7977 AstFactory.blockFunctionBody2([])); 7867 AstFactory.blockFunctionBody2([]));
7978 methodDeclaration.accept(builder); 7868 methodDeclaration.accept(builder);
7979 List<FieldElement> fields = holder.fields; 7869 List<FieldElement> fields = holder.fields;
7980 EngineTestCase.assertLength(1, fields); 7870 EngineTestCase.assertLength(1, fields);
7981 FieldElement field = fields[0]; 7871 FieldElement field = fields[0];
7982 JUnitTestCase.assertNotNull(field); 7872 expect(field, isNotNull);
7983 JUnitTestCase.assertEquals(methodName, field.name); 7873 expect(field.name, methodName);
7984 JUnitTestCase.assertTrue(field.isSynthetic); 7874 expect(field.isSynthetic, isTrue);
7985 JUnitTestCase.assertNull(field.getter); 7875 expect(field.getter, isNull);
7986 PropertyAccessorElement setter = field.setter; 7876 PropertyAccessorElement setter = field.setter;
7987 JUnitTestCase.assertNotNull(setter); 7877 expect(setter, isNotNull);
7988 JUnitTestCase.assertFalse(setter.isAbstract); 7878 expect(setter.isAbstract, isFalse);
7989 JUnitTestCase.assertTrue(setter.isSetter); 7879 expect(setter.isSetter, isTrue);
7990 JUnitTestCase.assertFalse(setter.isSynthetic); 7880 expect(setter.isSynthetic, isFalse);
7991 JUnitTestCase.assertEquals("$methodName=", setter.name); 7881 expect(setter.name, "$methodName=");
7992 JUnitTestCase.assertEquals(methodName, setter.displayName); 7882 expect(setter.displayName, methodName);
7993 JUnitTestCase.assertEquals(field, setter.variable); 7883 expect(setter.variable, field);
7994 EngineTestCase.assertLength(0, setter.functions); 7884 EngineTestCase.assertLength(0, setter.functions);
7995 EngineTestCase.assertLength(0, setter.labels); 7885 EngineTestCase.assertLength(0, setter.labels);
7996 EngineTestCase.assertLength(0, setter.localVariables); 7886 EngineTestCase.assertLength(0, setter.localVariables);
7997 EngineTestCase.assertLength(0, setter.parameters); 7887 EngineTestCase.assertLength(0, setter.parameters);
7998 } 7888 }
7999 7889
8000 void test_visitMethodDeclaration_setter_abstract() { 7890 void test_visitMethodDeclaration_setter_abstract() {
8001 ElementHolder holder = new ElementHolder(); 7891 ElementHolder holder = new ElementHolder();
8002 ElementBuilder builder = new ElementBuilder(holder); 7892 ElementBuilder builder = new ElementBuilder(holder);
8003 String methodName = "m"; 7893 String methodName = "m";
8004 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7894 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
8005 null, 7895 null,
8006 null, 7896 null,
8007 Keyword.SET, 7897 Keyword.SET,
8008 null, 7898 null,
8009 AstFactory.identifier3(methodName), 7899 AstFactory.identifier3(methodName),
8010 AstFactory.formalParameterList([]), 7900 AstFactory.formalParameterList([]),
8011 AstFactory.emptyFunctionBody()); 7901 AstFactory.emptyFunctionBody());
8012 methodDeclaration.accept(builder); 7902 methodDeclaration.accept(builder);
8013 List<FieldElement> fields = holder.fields; 7903 List<FieldElement> fields = holder.fields;
8014 EngineTestCase.assertLength(1, fields); 7904 EngineTestCase.assertLength(1, fields);
8015 FieldElement field = fields[0]; 7905 FieldElement field = fields[0];
8016 JUnitTestCase.assertNotNull(field); 7906 expect(field, isNotNull);
8017 JUnitTestCase.assertEquals(methodName, field.name); 7907 expect(field.name, methodName);
8018 JUnitTestCase.assertTrue(field.isSynthetic); 7908 expect(field.isSynthetic, isTrue);
8019 JUnitTestCase.assertNull(field.getter); 7909 expect(field.getter, isNull);
8020 PropertyAccessorElement setter = field.setter; 7910 PropertyAccessorElement setter = field.setter;
8021 JUnitTestCase.assertNotNull(setter); 7911 expect(setter, isNotNull);
8022 JUnitTestCase.assertTrue(setter.isAbstract); 7912 expect(setter.isAbstract, isTrue);
8023 JUnitTestCase.assertTrue(setter.isSetter); 7913 expect(setter.isSetter, isTrue);
8024 JUnitTestCase.assertFalse(setter.isSynthetic); 7914 expect(setter.isSynthetic, isFalse);
8025 JUnitTestCase.assertEquals("$methodName=", setter.name); 7915 expect(setter.name, "$methodName=");
8026 JUnitTestCase.assertEquals(methodName, setter.displayName); 7916 expect(setter.displayName, methodName);
8027 JUnitTestCase.assertEquals(field, setter.variable); 7917 expect(setter.variable, field);
8028 EngineTestCase.assertLength(0, setter.functions); 7918 EngineTestCase.assertLength(0, setter.functions);
8029 EngineTestCase.assertLength(0, setter.labels); 7919 EngineTestCase.assertLength(0, setter.labels);
8030 EngineTestCase.assertLength(0, setter.localVariables); 7920 EngineTestCase.assertLength(0, setter.localVariables);
8031 EngineTestCase.assertLength(0, setter.parameters); 7921 EngineTestCase.assertLength(0, setter.parameters);
8032 } 7922 }
8033 7923
8034 void test_visitMethodDeclaration_setter_external() { 7924 void test_visitMethodDeclaration_setter_external() {
8035 ElementHolder holder = new ElementHolder(); 7925 ElementHolder holder = new ElementHolder();
8036 ElementBuilder builder = new ElementBuilder(holder); 7926 ElementBuilder builder = new ElementBuilder(holder);
8037 String methodName = "m"; 7927 String methodName = "m";
8038 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration( 7928 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration(
8039 null, 7929 null,
8040 null, 7930 null,
8041 Keyword.SET, 7931 Keyword.SET,
8042 null, 7932 null,
8043 AstFactory.identifier3(methodName), 7933 AstFactory.identifier3(methodName),
8044 AstFactory.formalParameterList([])); 7934 AstFactory.formalParameterList([]));
8045 methodDeclaration.accept(builder); 7935 methodDeclaration.accept(builder);
8046 List<FieldElement> fields = holder.fields; 7936 List<FieldElement> fields = holder.fields;
8047 EngineTestCase.assertLength(1, fields); 7937 EngineTestCase.assertLength(1, fields);
8048 FieldElement field = fields[0]; 7938 FieldElement field = fields[0];
8049 JUnitTestCase.assertNotNull(field); 7939 expect(field, isNotNull);
8050 JUnitTestCase.assertEquals(methodName, field.name); 7940 expect(field.name, methodName);
8051 JUnitTestCase.assertTrue(field.isSynthetic); 7941 expect(field.isSynthetic, isTrue);
8052 JUnitTestCase.assertNull(field.getter); 7942 expect(field.getter, isNull);
8053 PropertyAccessorElement setter = field.setter; 7943 PropertyAccessorElement setter = field.setter;
8054 JUnitTestCase.assertNotNull(setter); 7944 expect(setter, isNotNull);
8055 JUnitTestCase.assertFalse(setter.isAbstract); 7945 expect(setter.isAbstract, isFalse);
8056 JUnitTestCase.assertTrue(setter.isSetter); 7946 expect(setter.isSetter, isTrue);
8057 JUnitTestCase.assertFalse(setter.isSynthetic); 7947 expect(setter.isSynthetic, isFalse);
8058 JUnitTestCase.assertEquals("$methodName=", setter.name); 7948 expect(setter.name, "$methodName=");
8059 JUnitTestCase.assertEquals(methodName, setter.displayName); 7949 expect(setter.displayName, methodName);
8060 JUnitTestCase.assertEquals(field, setter.variable); 7950 expect(setter.variable, field);
8061 EngineTestCase.assertLength(0, setter.functions); 7951 EngineTestCase.assertLength(0, setter.functions);
8062 EngineTestCase.assertLength(0, setter.labels); 7952 EngineTestCase.assertLength(0, setter.labels);
8063 EngineTestCase.assertLength(0, setter.localVariables); 7953 EngineTestCase.assertLength(0, setter.localVariables);
8064 EngineTestCase.assertLength(0, setter.parameters); 7954 EngineTestCase.assertLength(0, setter.parameters);
8065 } 7955 }
8066 7956
8067 void test_visitMethodDeclaration_static() { 7957 void test_visitMethodDeclaration_static() {
8068 ElementHolder holder = new ElementHolder(); 7958 ElementHolder holder = new ElementHolder();
8069 ElementBuilder builder = new ElementBuilder(holder); 7959 ElementBuilder builder = new ElementBuilder(holder);
8070 String methodName = "m"; 7960 String methodName = "m";
8071 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7961 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
8072 Keyword.STATIC, 7962 Keyword.STATIC,
8073 null, 7963 null,
8074 null, 7964 null,
8075 null, 7965 null,
8076 AstFactory.identifier3(methodName), 7966 AstFactory.identifier3(methodName),
8077 AstFactory.formalParameterList([]), 7967 AstFactory.formalParameterList([]),
8078 AstFactory.blockFunctionBody2([])); 7968 AstFactory.blockFunctionBody2([]));
8079 methodDeclaration.accept(builder); 7969 methodDeclaration.accept(builder);
8080 List<MethodElement> methods = holder.methods; 7970 List<MethodElement> methods = holder.methods;
8081 EngineTestCase.assertLength(1, methods); 7971 EngineTestCase.assertLength(1, methods);
8082 MethodElement method = methods[0]; 7972 MethodElement method = methods[0];
8083 JUnitTestCase.assertNotNull(method); 7973 expect(method, isNotNull);
8084 JUnitTestCase.assertEquals(methodName, method.name); 7974 expect(method.name, methodName);
8085 EngineTestCase.assertLength(0, method.functions); 7975 EngineTestCase.assertLength(0, method.functions);
8086 EngineTestCase.assertLength(0, method.labels); 7976 EngineTestCase.assertLength(0, method.labels);
8087 EngineTestCase.assertLength(0, method.localVariables); 7977 EngineTestCase.assertLength(0, method.localVariables);
8088 EngineTestCase.assertLength(0, method.parameters); 7978 EngineTestCase.assertLength(0, method.parameters);
8089 JUnitTestCase.assertFalse(method.isAbstract); 7979 expect(method.isAbstract, isFalse);
8090 JUnitTestCase.assertTrue(method.isStatic); 7980 expect(method.isStatic, isTrue);
8091 JUnitTestCase.assertFalse(method.isSynthetic); 7981 expect(method.isSynthetic, isFalse);
8092 } 7982 }
8093 7983
8094 void test_visitMethodDeclaration_withMembers() { 7984 void test_visitMethodDeclaration_withMembers() {
8095 ElementHolder holder = new ElementHolder(); 7985 ElementHolder holder = new ElementHolder();
8096 ElementBuilder builder = new ElementBuilder(holder); 7986 ElementBuilder builder = new ElementBuilder(holder);
8097 String methodName = "m"; 7987 String methodName = "m";
8098 String parameterName = "p"; 7988 String parameterName = "p";
8099 String localVariableName = "v"; 7989 String localVariableName = "v";
8100 String labelName = "l"; 7990 String labelName = "l";
8101 String exceptionParameterName = "e"; 7991 String exceptionParameterName = "e";
(...skipping 14 matching lines...) Expand all
8116 AstFactory.block( 8006 AstFactory.block(
8117 [ 8007 [
8118 AstFactory.labeledStatement( 8008 AstFactory.labeledStatement(
8119 AstFactory.list([AstFactory.label2(labelName)]), 8009 AstFactory.list([AstFactory.label2(labelName)]),
8120 AstFactory.returnStatement())]), 8010 AstFactory.returnStatement())]),
8121 [AstFactory.catchClause(exceptionParameterName, [])])])); 8011 [AstFactory.catchClause(exceptionParameterName, [])])]));
8122 methodDeclaration.accept(builder); 8012 methodDeclaration.accept(builder);
8123 List<MethodElement> methods = holder.methods; 8013 List<MethodElement> methods = holder.methods;
8124 EngineTestCase.assertLength(1, methods); 8014 EngineTestCase.assertLength(1, methods);
8125 MethodElement method = methods[0]; 8015 MethodElement method = methods[0];
8126 JUnitTestCase.assertNotNull(method); 8016 expect(method, isNotNull);
8127 JUnitTestCase.assertEquals(methodName, method.name); 8017 expect(method.name, methodName);
8128 JUnitTestCase.assertFalse(method.isAbstract); 8018 expect(method.isAbstract, isFalse);
8129 JUnitTestCase.assertFalse(method.isStatic); 8019 expect(method.isStatic, isFalse);
8130 JUnitTestCase.assertFalse(method.isSynthetic); 8020 expect(method.isSynthetic, isFalse);
8131 List<VariableElement> parameters = method.parameters; 8021 List<VariableElement> parameters = method.parameters;
8132 EngineTestCase.assertLength(1, parameters); 8022 EngineTestCase.assertLength(1, parameters);
8133 VariableElement parameter = parameters[0]; 8023 VariableElement parameter = parameters[0];
8134 JUnitTestCase.assertNotNull(parameter); 8024 expect(parameter, isNotNull);
8135 JUnitTestCase.assertEquals(parameterName, parameter.name); 8025 expect(parameter.name, parameterName);
8136 List<VariableElement> localVariables = method.localVariables; 8026 List<VariableElement> localVariables = method.localVariables;
8137 EngineTestCase.assertLength(2, localVariables); 8027 EngineTestCase.assertLength(2, localVariables);
8138 VariableElement firstVariable = localVariables[0]; 8028 VariableElement firstVariable = localVariables[0];
8139 VariableElement secondVariable = localVariables[1]; 8029 VariableElement secondVariable = localVariables[1];
8140 JUnitTestCase.assertNotNull(firstVariable); 8030 expect(firstVariable, isNotNull);
8141 JUnitTestCase.assertNotNull(secondVariable); 8031 expect(secondVariable, isNotNull);
8142 JUnitTestCase.assertTrue( 8032 expect((firstVariable.name == localVariableName &&
8143 (firstVariable.name == localVariableName &&
8144 secondVariable.name == exceptionParameterName) || 8033 secondVariable.name == exceptionParameterName) ||
8145 (firstVariable.name == exceptionParameterName && 8034 (firstVariable.name == exceptionParameterName &&
8146 secondVariable.name == localVariableName)); 8035 secondVariable.name == localVariableName), isTrue);
8147 List<LabelElement> labels = method.labels; 8036 List<LabelElement> labels = method.labels;
8148 EngineTestCase.assertLength(1, labels); 8037 EngineTestCase.assertLength(1, labels);
8149 LabelElement label = labels[0]; 8038 LabelElement label = labels[0];
8150 JUnitTestCase.assertNotNull(label); 8039 expect(label, isNotNull);
8151 JUnitTestCase.assertEquals(labelName, label.name); 8040 expect(label.name, labelName);
8152 } 8041 }
8153 8042
8154 void test_visitNamedFormalParameter() { 8043 void test_visitNamedFormalParameter() {
8155 ElementHolder holder = new ElementHolder(); 8044 ElementHolder holder = new ElementHolder();
8156 ElementBuilder builder = new ElementBuilder(holder); 8045 ElementBuilder builder = new ElementBuilder(holder);
8157 String parameterName = "p"; 8046 String parameterName = "p";
8158 DefaultFormalParameter formalParameter = AstFactory.namedFormalParameter( 8047 DefaultFormalParameter formalParameter = AstFactory.namedFormalParameter(
8159 AstFactory.simpleFormalParameter3(parameterName), 8048 AstFactory.simpleFormalParameter3(parameterName),
8160 AstFactory.identifier3("42")); 8049 AstFactory.identifier3("42"));
8161 _useParameterInMethod(formalParameter, 100, 110); 8050 _useParameterInMethod(formalParameter, 100, 110);
8162 formalParameter.accept(builder); 8051 formalParameter.accept(builder);
8163 List<ParameterElement> parameters = holder.parameters; 8052 List<ParameterElement> parameters = holder.parameters;
8164 EngineTestCase.assertLength(1, parameters); 8053 EngineTestCase.assertLength(1, parameters);
8165 ParameterElement parameter = parameters[0]; 8054 ParameterElement parameter = parameters[0];
8166 JUnitTestCase.assertNotNull(parameter); 8055 expect(parameter, isNotNull);
8167 JUnitTestCase.assertEquals(parameterName, parameter.name); 8056 expect(parameter.name, parameterName);
8168 JUnitTestCase.assertFalse(parameter.isConst); 8057 expect(parameter.isConst, isFalse);
8169 JUnitTestCase.assertFalse(parameter.isFinal); 8058 expect(parameter.isFinal, isFalse);
8170 JUnitTestCase.assertFalse(parameter.isSynthetic); 8059 expect(parameter.isSynthetic, isFalse);
8171 JUnitTestCase.assertEquals(ParameterKind.NAMED, parameter.parameterKind); 8060 expect(parameter.parameterKind, ParameterKind.NAMED);
8172 { 8061 {
8173 SourceRange visibleRange = parameter.visibleRange; 8062 SourceRange visibleRange = parameter.visibleRange;
8174 JUnitTestCase.assertEquals(visibleRange.offset, 100); 8063 expect(100, visibleRange.offset);
8175 JUnitTestCase.assertEquals(visibleRange.end, 110); 8064 expect(110, visibleRange.end);
8176 } 8065 }
8177 JUnitTestCase.assertEquals("42", parameter.defaultValueCode); 8066 expect(parameter.defaultValueCode, "42");
8178 FunctionElement initializer = parameter.initializer; 8067 FunctionElement initializer = parameter.initializer;
8179 JUnitTestCase.assertNotNull(initializer); 8068 expect(initializer, isNotNull);
8180 JUnitTestCase.assertTrue(initializer.isSynthetic); 8069 expect(initializer.isSynthetic, isTrue);
8181 } 8070 }
8182 8071
8183 void test_visitSimpleFormalParameter() { 8072 void test_visitSimpleFormalParameter() {
8184 ElementHolder holder = new ElementHolder(); 8073 ElementHolder holder = new ElementHolder();
8185 ElementBuilder builder = new ElementBuilder(holder); 8074 ElementBuilder builder = new ElementBuilder(holder);
8186 String parameterName = "p"; 8075 String parameterName = "p";
8187 SimpleFormalParameter formalParameter = 8076 SimpleFormalParameter formalParameter =
8188 AstFactory.simpleFormalParameter3(parameterName); 8077 AstFactory.simpleFormalParameter3(parameterName);
8189 _useParameterInMethod(formalParameter, 100, 110); 8078 _useParameterInMethod(formalParameter, 100, 110);
8190 formalParameter.accept(builder); 8079 formalParameter.accept(builder);
8191 List<ParameterElement> parameters = holder.parameters; 8080 List<ParameterElement> parameters = holder.parameters;
8192 EngineTestCase.assertLength(1, parameters); 8081 EngineTestCase.assertLength(1, parameters);
8193 ParameterElement parameter = parameters[0]; 8082 ParameterElement parameter = parameters[0];
8194 JUnitTestCase.assertNotNull(parameter); 8083 expect(parameter, isNotNull);
8195 JUnitTestCase.assertEquals(parameterName, parameter.name); 8084 expect(parameter.name, parameterName);
8196 JUnitTestCase.assertNull(parameter.initializer); 8085 expect(parameter.initializer, isNull);
8197 JUnitTestCase.assertFalse(parameter.isConst); 8086 expect(parameter.isConst, isFalse);
8198 JUnitTestCase.assertFalse(parameter.isFinal); 8087 expect(parameter.isFinal, isFalse);
8199 JUnitTestCase.assertFalse(parameter.isSynthetic); 8088 expect(parameter.isSynthetic, isFalse);
8200 JUnitTestCase.assertEquals(ParameterKind.REQUIRED, parameter.parameterKind); 8089 expect(parameter.parameterKind, ParameterKind.REQUIRED);
8201 { 8090 {
8202 SourceRange visibleRange = parameter.visibleRange; 8091 SourceRange visibleRange = parameter.visibleRange;
8203 JUnitTestCase.assertEquals(visibleRange.offset, 100); 8092 expect(100, visibleRange.offset);
8204 JUnitTestCase.assertEquals(visibleRange.end, 110); 8093 expect(110, visibleRange.end);
8205 } 8094 }
8206 } 8095 }
8207 8096
8208 void test_visitTypeAlias_minimal() { 8097 void test_visitTypeAlias_minimal() {
8209 ElementHolder holder = new ElementHolder(); 8098 ElementHolder holder = new ElementHolder();
8210 ElementBuilder builder = new ElementBuilder(holder); 8099 ElementBuilder builder = new ElementBuilder(holder);
8211 String aliasName = "F"; 8100 String aliasName = "F";
8212 TypeAlias typeAlias = AstFactory.typeAlias(null, aliasName, null, null); 8101 TypeAlias typeAlias = AstFactory.typeAlias(null, aliasName, null, null);
8213 typeAlias.accept(builder); 8102 typeAlias.accept(builder);
8214 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 8103 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
8215 EngineTestCase.assertLength(1, aliases); 8104 EngineTestCase.assertLength(1, aliases);
8216 FunctionTypeAliasElement alias = aliases[0]; 8105 FunctionTypeAliasElement alias = aliases[0];
8217 JUnitTestCase.assertNotNull(alias); 8106 expect(alias, isNotNull);
8218 JUnitTestCase.assertEquals(aliasName, alias.name); 8107 expect(alias.name, aliasName);
8219 JUnitTestCase.assertNotNull(alias.type); 8108 expect(alias.type, isNotNull);
8220 JUnitTestCase.assertFalse(alias.isSynthetic); 8109 expect(alias.isSynthetic, isFalse);
8221 } 8110 }
8222 8111
8223 void test_visitTypeAlias_withFormalParameters() { 8112 void test_visitTypeAlias_withFormalParameters() {
8224 ElementHolder holder = new ElementHolder(); 8113 ElementHolder holder = new ElementHolder();
8225 ElementBuilder builder = new ElementBuilder(holder); 8114 ElementBuilder builder = new ElementBuilder(holder);
8226 String aliasName = "F"; 8115 String aliasName = "F";
8227 String firstParameterName = "x"; 8116 String firstParameterName = "x";
8228 String secondParameterName = "y"; 8117 String secondParameterName = "y";
8229 TypeAlias typeAlias = AstFactory.typeAlias( 8118 TypeAlias typeAlias = AstFactory.typeAlias(
8230 null, 8119 null,
8231 aliasName, 8120 aliasName,
8232 AstFactory.typeParameterList([]), 8121 AstFactory.typeParameterList([]),
8233 AstFactory.formalParameterList( 8122 AstFactory.formalParameterList(
8234 [ 8123 [
8235 AstFactory.simpleFormalParameter3(firstParameterName), 8124 AstFactory.simpleFormalParameter3(firstParameterName),
8236 AstFactory.simpleFormalParameter3(secondParameterName)])); 8125 AstFactory.simpleFormalParameter3(secondParameterName)]));
8237 typeAlias.accept(builder); 8126 typeAlias.accept(builder);
8238 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 8127 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
8239 EngineTestCase.assertLength(1, aliases); 8128 EngineTestCase.assertLength(1, aliases);
8240 FunctionTypeAliasElement alias = aliases[0]; 8129 FunctionTypeAliasElement alias = aliases[0];
8241 JUnitTestCase.assertNotNull(alias); 8130 expect(alias, isNotNull);
8242 JUnitTestCase.assertEquals(aliasName, alias.name); 8131 expect(alias.name, aliasName);
8243 JUnitTestCase.assertNotNull(alias.type); 8132 expect(alias.type, isNotNull);
8244 JUnitTestCase.assertFalse(alias.isSynthetic); 8133 expect(alias.isSynthetic, isFalse);
8245 List<VariableElement> parameters = alias.parameters; 8134 List<VariableElement> parameters = alias.parameters;
8246 EngineTestCase.assertLength(2, parameters); 8135 EngineTestCase.assertLength(2, parameters);
8247 JUnitTestCase.assertEquals(firstParameterName, parameters[0].name); 8136 expect(parameters[0].name, firstParameterName);
8248 JUnitTestCase.assertEquals(secondParameterName, parameters[1].name); 8137 expect(parameters[1].name, secondParameterName);
8249 List<TypeParameterElement> typeParameters = alias.typeParameters; 8138 List<TypeParameterElement> typeParameters = alias.typeParameters;
8250 JUnitTestCase.assertNotNull(typeParameters); 8139 expect(typeParameters, isNotNull);
8251 EngineTestCase.assertLength(0, typeParameters); 8140 EngineTestCase.assertLength(0, typeParameters);
8252 } 8141 }
8253 8142
8254 void test_visitTypeAlias_withTypeParameters() { 8143 void test_visitTypeAlias_withTypeParameters() {
8255 ElementHolder holder = new ElementHolder(); 8144 ElementHolder holder = new ElementHolder();
8256 ElementBuilder builder = new ElementBuilder(holder); 8145 ElementBuilder builder = new ElementBuilder(holder);
8257 String aliasName = "F"; 8146 String aliasName = "F";
8258 String firstTypeParameterName = "A"; 8147 String firstTypeParameterName = "A";
8259 String secondTypeParameterName = "B"; 8148 String secondTypeParameterName = "B";
8260 TypeAlias typeAlias = AstFactory.typeAlias( 8149 TypeAlias typeAlias = AstFactory.typeAlias(
8261 null, 8150 null,
8262 aliasName, 8151 aliasName,
8263 AstFactory.typeParameterList([firstTypeParameterName, secondTypeParamete rName]), 8152 AstFactory.typeParameterList([firstTypeParameterName, secondTypeParamete rName]),
8264 AstFactory.formalParameterList([])); 8153 AstFactory.formalParameterList([]));
8265 typeAlias.accept(builder); 8154 typeAlias.accept(builder);
8266 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 8155 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
8267 EngineTestCase.assertLength(1, aliases); 8156 EngineTestCase.assertLength(1, aliases);
8268 FunctionTypeAliasElement alias = aliases[0]; 8157 FunctionTypeAliasElement alias = aliases[0];
8269 JUnitTestCase.assertNotNull(alias); 8158 expect(alias, isNotNull);
8270 JUnitTestCase.assertEquals(aliasName, alias.name); 8159 expect(alias.name, aliasName);
8271 JUnitTestCase.assertNotNull(alias.type); 8160 expect(alias.type, isNotNull);
8272 JUnitTestCase.assertFalse(alias.isSynthetic); 8161 expect(alias.isSynthetic, isFalse);
8273 List<VariableElement> parameters = alias.parameters; 8162 List<VariableElement> parameters = alias.parameters;
8274 JUnitTestCase.assertNotNull(parameters); 8163 expect(parameters, isNotNull);
8275 EngineTestCase.assertLength(0, parameters); 8164 EngineTestCase.assertLength(0, parameters);
8276 List<TypeParameterElement> typeParameters = alias.typeParameters; 8165 List<TypeParameterElement> typeParameters = alias.typeParameters;
8277 EngineTestCase.assertLength(2, typeParameters); 8166 EngineTestCase.assertLength(2, typeParameters);
8278 JUnitTestCase.assertEquals(firstTypeParameterName, typeParameters[0].name); 8167 expect(typeParameters[0].name, firstTypeParameterName);
8279 JUnitTestCase.assertEquals(secondTypeParameterName, typeParameters[1].name); 8168 expect(typeParameters[1].name, secondTypeParameterName);
8280 } 8169 }
8281 8170
8282 void test_visitTypeParameter() { 8171 void test_visitTypeParameter() {
8283 ElementHolder holder = new ElementHolder(); 8172 ElementHolder holder = new ElementHolder();
8284 ElementBuilder builder = new ElementBuilder(holder); 8173 ElementBuilder builder = new ElementBuilder(holder);
8285 String parameterName = "E"; 8174 String parameterName = "E";
8286 TypeParameter typeParameter = AstFactory.typeParameter(parameterName); 8175 TypeParameter typeParameter = AstFactory.typeParameter(parameterName);
8287 typeParameter.accept(builder); 8176 typeParameter.accept(builder);
8288 List<TypeParameterElement> typeParameters = holder.typeParameters; 8177 List<TypeParameterElement> typeParameters = holder.typeParameters;
8289 EngineTestCase.assertLength(1, typeParameters); 8178 EngineTestCase.assertLength(1, typeParameters);
8290 TypeParameterElement typeParameterElement = typeParameters[0]; 8179 TypeParameterElement typeParameterElement = typeParameters[0];
8291 JUnitTestCase.assertNotNull(typeParameterElement); 8180 expect(typeParameterElement, isNotNull);
8292 JUnitTestCase.assertEquals(parameterName, typeParameterElement.name); 8181 expect(typeParameterElement.name, parameterName);
8293 JUnitTestCase.assertNull(typeParameterElement.bound); 8182 expect(typeParameterElement.bound, isNull);
8294 JUnitTestCase.assertFalse(typeParameterElement.isSynthetic); 8183 expect(typeParameterElement.isSynthetic, isFalse);
8295 } 8184 }
8296 8185
8297 void test_visitVariableDeclaration_inConstructor() { 8186 void test_visitVariableDeclaration_inConstructor() {
8298 ElementHolder holder = new ElementHolder(); 8187 ElementHolder holder = new ElementHolder();
8299 ElementBuilder builder = new ElementBuilder(holder); 8188 ElementBuilder builder = new ElementBuilder(holder);
8300 // 8189 //
8301 // C() {var v;} 8190 // C() {var v;}
8302 // 8191 //
8303 String variableName = "v"; 8192 String variableName = "v";
8304 VariableDeclaration variable = 8193 VariableDeclaration variable =
8305 AstFactory.variableDeclaration2(variableName, null); 8194 AstFactory.variableDeclaration2(variableName, null);
8306 Statement statement = 8195 Statement statement =
8307 AstFactory.variableDeclarationStatement2(null, [variable]); 8196 AstFactory.variableDeclarationStatement2(null, [variable]);
8308 ConstructorDeclaration constructor = AstFactory.constructorDeclaration2( 8197 ConstructorDeclaration constructor = AstFactory.constructorDeclaration2(
8309 null, 8198 null,
8310 null, 8199 null,
8311 AstFactory.identifier3("C"), 8200 AstFactory.identifier3("C"),
8312 "C", 8201 "C",
8313 AstFactory.formalParameterList([]), 8202 AstFactory.formalParameterList([]),
8314 null, 8203 null,
8315 AstFactory.blockFunctionBody2([statement])); 8204 AstFactory.blockFunctionBody2([statement]));
8316 constructor.accept(builder); 8205 constructor.accept(builder);
8317 List<ConstructorElement> constructors = holder.constructors; 8206 List<ConstructorElement> constructors = holder.constructors;
8318 EngineTestCase.assertLength(1, constructors); 8207 EngineTestCase.assertLength(1, constructors);
8319 List<LocalVariableElement> variableElements = 8208 List<LocalVariableElement> variableElements =
8320 constructors[0].localVariables; 8209 constructors[0].localVariables;
8321 EngineTestCase.assertLength(1, variableElements); 8210 EngineTestCase.assertLength(1, variableElements);
8322 LocalVariableElement variableElement = variableElements[0]; 8211 LocalVariableElement variableElement = variableElements[0];
8323 JUnitTestCase.assertEquals(variableName, variableElement.name); 8212 expect(variableElement.name, variableName);
8324 } 8213 }
8325 8214
8326 void test_visitVariableDeclaration_inMethod() { 8215 void test_visitVariableDeclaration_inMethod() {
8327 ElementHolder holder = new ElementHolder(); 8216 ElementHolder holder = new ElementHolder();
8328 ElementBuilder builder = new ElementBuilder(holder); 8217 ElementBuilder builder = new ElementBuilder(holder);
8329 // 8218 //
8330 // m() {var v;} 8219 // m() {var v;}
8331 // 8220 //
8332 String variableName = "v"; 8221 String variableName = "v";
8333 VariableDeclaration variable = 8222 VariableDeclaration variable =
8334 AstFactory.variableDeclaration2(variableName, null); 8223 AstFactory.variableDeclaration2(variableName, null);
8335 Statement statement = 8224 Statement statement =
8336 AstFactory.variableDeclarationStatement2(null, [variable]); 8225 AstFactory.variableDeclarationStatement2(null, [variable]);
8337 MethodDeclaration constructor = AstFactory.methodDeclaration2( 8226 MethodDeclaration constructor = AstFactory.methodDeclaration2(
8338 null, 8227 null,
8339 null, 8228 null,
8340 null, 8229 null,
8341 null, 8230 null,
8342 AstFactory.identifier3("m"), 8231 AstFactory.identifier3("m"),
8343 AstFactory.formalParameterList([]), 8232 AstFactory.formalParameterList([]),
8344 AstFactory.blockFunctionBody2([statement])); 8233 AstFactory.blockFunctionBody2([statement]));
8345 constructor.accept(builder); 8234 constructor.accept(builder);
8346 List<MethodElement> methods = holder.methods; 8235 List<MethodElement> methods = holder.methods;
8347 EngineTestCase.assertLength(1, methods); 8236 EngineTestCase.assertLength(1, methods);
8348 List<LocalVariableElement> variableElements = methods[0].localVariables; 8237 List<LocalVariableElement> variableElements = methods[0].localVariables;
8349 EngineTestCase.assertLength(1, variableElements); 8238 EngineTestCase.assertLength(1, variableElements);
8350 LocalVariableElement variableElement = variableElements[0]; 8239 LocalVariableElement variableElement = variableElements[0];
8351 JUnitTestCase.assertEquals(variableName, variableElement.name); 8240 expect(variableElement.name, variableName);
8352 } 8241 }
8353 8242
8354 void test_visitVariableDeclaration_localNestedInField() { 8243 void test_visitVariableDeclaration_localNestedInField() {
8355 ElementHolder holder = new ElementHolder(); 8244 ElementHolder holder = new ElementHolder();
8356 ElementBuilder builder = new ElementBuilder(holder); 8245 ElementBuilder builder = new ElementBuilder(holder);
8357 // 8246 //
8358 // var f = () {var v;} 8247 // var f = () {var v;}
8359 // 8248 //
8360 String variableName = "v"; 8249 String variableName = "v";
8361 VariableDeclaration variable = 8250 VariableDeclaration variable =
8362 AstFactory.variableDeclaration2(variableName, null); 8251 AstFactory.variableDeclaration2(variableName, null);
8363 Statement statement = 8252 Statement statement =
8364 AstFactory.variableDeclarationStatement2(null, [variable]); 8253 AstFactory.variableDeclarationStatement2(null, [variable]);
8365 Expression initializer = AstFactory.functionExpression2( 8254 Expression initializer = AstFactory.functionExpression2(
8366 AstFactory.formalParameterList([]), 8255 AstFactory.formalParameterList([]),
8367 AstFactory.blockFunctionBody2([statement])); 8256 AstFactory.blockFunctionBody2([statement]));
8368 String fieldName = "f"; 8257 String fieldName = "f";
8369 VariableDeclaration field = 8258 VariableDeclaration field =
8370 AstFactory.variableDeclaration2(fieldName, initializer); 8259 AstFactory.variableDeclaration2(fieldName, initializer);
8371 FieldDeclaration fieldDeclaration = 8260 FieldDeclaration fieldDeclaration =
8372 AstFactory.fieldDeclaration2(false, null, [field]); 8261 AstFactory.fieldDeclaration2(false, null, [field]);
8373 fieldDeclaration.accept(builder); 8262 fieldDeclaration.accept(builder);
8374 List<FieldElement> variables = holder.fields; 8263 List<FieldElement> variables = holder.fields;
8375 EngineTestCase.assertLength(1, variables); 8264 EngineTestCase.assertLength(1, variables);
8376 FieldElement fieldElement = variables[0]; 8265 FieldElement fieldElement = variables[0];
8377 JUnitTestCase.assertNotNull(fieldElement); 8266 expect(fieldElement, isNotNull);
8378 FunctionElement initializerElement = fieldElement.initializer; 8267 FunctionElement initializerElement = fieldElement.initializer;
8379 JUnitTestCase.assertNotNull(initializerElement); 8268 expect(initializerElement, isNotNull);
8380 List<FunctionElement> functionElements = initializerElement.functions; 8269 List<FunctionElement> functionElements = initializerElement.functions;
8381 EngineTestCase.assertLength(1, functionElements); 8270 EngineTestCase.assertLength(1, functionElements);
8382 List<LocalVariableElement> variableElements = 8271 List<LocalVariableElement> variableElements =
8383 functionElements[0].localVariables; 8272 functionElements[0].localVariables;
8384 EngineTestCase.assertLength(1, variableElements); 8273 EngineTestCase.assertLength(1, variableElements);
8385 LocalVariableElement variableElement = variableElements[0]; 8274 LocalVariableElement variableElement = variableElements[0];
8386 JUnitTestCase.assertEquals(variableName, variableElement.name); 8275 expect(variableElement.name, variableName);
8387 JUnitTestCase.assertFalse(variableElement.isConst); 8276 expect(variableElement.isConst, isFalse);
8388 JUnitTestCase.assertFalse(variableElement.isFinal); 8277 expect(variableElement.isFinal, isFalse);
8389 JUnitTestCase.assertFalse(variableElement.isSynthetic); 8278 expect(variableElement.isSynthetic, isFalse);
8390 } 8279 }
8391 8280
8392 void test_visitVariableDeclaration_noInitializer() { 8281 void test_visitVariableDeclaration_noInitializer() {
8393 ElementHolder holder = new ElementHolder(); 8282 ElementHolder holder = new ElementHolder();
8394 ElementBuilder builder = new ElementBuilder(holder); 8283 ElementBuilder builder = new ElementBuilder(holder);
8395 String variableName = "v"; 8284 String variableName = "v";
8396 VariableDeclaration variableDeclaration = 8285 VariableDeclaration variableDeclaration =
8397 AstFactory.variableDeclaration2(variableName, null); 8286 AstFactory.variableDeclaration2(variableName, null);
8398 AstFactory.variableDeclarationList2(null, [variableDeclaration]); 8287 AstFactory.variableDeclarationList2(null, [variableDeclaration]);
8399 variableDeclaration.accept(builder); 8288 variableDeclaration.accept(builder);
8400 List<TopLevelVariableElement> variables = holder.topLevelVariables; 8289 List<TopLevelVariableElement> variables = holder.topLevelVariables;
8401 EngineTestCase.assertLength(1, variables); 8290 EngineTestCase.assertLength(1, variables);
8402 TopLevelVariableElement variable = variables[0]; 8291 TopLevelVariableElement variable = variables[0];
8403 JUnitTestCase.assertNotNull(variable); 8292 expect(variable, isNotNull);
8404 JUnitTestCase.assertNull(variable.initializer); 8293 expect(variable.initializer, isNull);
8405 JUnitTestCase.assertEquals(variableName, variable.name); 8294 expect(variable.name, variableName);
8406 JUnitTestCase.assertFalse(variable.isConst); 8295 expect(variable.isConst, isFalse);
8407 JUnitTestCase.assertFalse(variable.isFinal); 8296 expect(variable.isFinal, isFalse);
8408 JUnitTestCase.assertFalse(variable.isSynthetic); 8297 expect(variable.isSynthetic, isFalse);
8409 JUnitTestCase.assertNotNull(variable.getter); 8298 expect(variable.getter, isNotNull);
8410 JUnitTestCase.assertNotNull(variable.setter); 8299 expect(variable.setter, isNotNull);
8411 } 8300 }
8412 8301
8413 void _useParameterInMethod(FormalParameter formalParameter, int blockOffset, 8302 void _useParameterInMethod(FormalParameter formalParameter, int blockOffset,
8414 int blockEnd) { 8303 int blockEnd) {
8415 Block block = AstFactory.block([]); 8304 Block block = AstFactory.block([]);
8416 block.leftBracket.offset = blockOffset; 8305 block.leftBracket.offset = blockOffset;
8417 block.rightBracket.offset = blockEnd - 1; 8306 block.rightBracket.offset = blockEnd - 1;
8418 BlockFunctionBody body = AstFactory.blockFunctionBody(block); 8307 BlockFunctionBody body = AstFactory.blockFunctionBody(block);
8419 AstFactory.methodDeclaration2( 8308 AstFactory.methodDeclaration2(
8420 null, 8309 null,
(...skipping 24 matching lines...) Expand all
8445 (obj) => obj is LibraryElement, 8334 (obj) => obj is LibraryElement,
8446 LibraryElement, 8335 LibraryElement,
8447 element); 8336 element);
8448 } 8337 }
8449 8338
8450 void fail_locate_Identifier_partOfDirective() { 8339 void fail_locate_Identifier_partOfDirective() {
8451 // Can't resolve the library element without the library declaration. 8340 // Can't resolve the library element without the library declaration.
8452 // AstNode id = findNodeIn("foo", "part of foo.bar;"); 8341 // AstNode id = findNodeIn("foo", "part of foo.bar;");
8453 // Element element = ElementLocator.locate(id); 8342 // Element element = ElementLocator.locate(id);
8454 // assertInstanceOf(LibraryElement.class, element); 8343 // assertInstanceOf(LibraryElement.class, element);
8455 JUnitTestCase.fail("Test this case"); 8344 fail("Test this case");
8456 } 8345 }
8457 8346
8458 @override 8347 @override
8459 void reset() { 8348 void reset() {
8460 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); 8349 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl();
8461 analysisOptions.hint = false; 8350 analysisOptions.hint = false;
8462 resetWithOptions(analysisOptions); 8351 resetWithOptions(analysisOptions);
8463 } 8352 }
8464 8353
8465 void test_locateWithOffset_BinaryExpression() { 8354 void test_locateWithOffset_BinaryExpression() {
8466 AstNode id = _findNodeIn("+", "var x = 3 + 4;"); 8355 AstNode id = _findNodeIn("+", "var x = 3 + 4;");
8467 Element element = ElementLocator.locateWithOffset(id, 0); 8356 Element element = ElementLocator.locateWithOffset(id, 0);
8468 EngineTestCase.assertInstanceOf( 8357 EngineTestCase.assertInstanceOf(
8469 (obj) => obj is MethodElement, 8358 (obj) => obj is MethodElement,
8470 MethodElement, 8359 MethodElement,
8471 element); 8360 element);
8472 } 8361 }
8473 8362
8474 void test_locateWithOffset_StringLiteral() { 8363 void test_locateWithOffset_StringLiteral() {
8475 AstNode id = _findNodeIn("abc", "var x = 'abc';"); 8364 AstNode id = _findNodeIn("abc", "var x = 'abc';");
8476 Element element = ElementLocator.locateWithOffset(id, 1); 8365 Element element = ElementLocator.locateWithOffset(id, 1);
8477 JUnitTestCase.assertNull(element); 8366 expect(element, isNull);
8478 } 8367 }
8479 8368
8480 void test_locate_AssignmentExpression() { 8369 void test_locate_AssignmentExpression() {
8481 AstNode id = 8370 AstNode id =
8482 _findNodeIn("+=", r''' 8371 _findNodeIn("+=", r'''
8483 int x = 0; 8372 int x = 0;
8484 void main() { 8373 void main() {
8485 x += 1; 8374 x += 1;
8486 }'''); 8375 }''');
8487 Element element = ElementLocator.locate(id); 8376 Element element = ElementLocator.locate(id);
(...skipping 16 matching lines...) Expand all
8504 AstNode id = _findNodeIn("class", "class A { }"); 8393 AstNode id = _findNodeIn("class", "class A { }");
8505 Element element = ElementLocator.locate(id); 8394 Element element = ElementLocator.locate(id);
8506 EngineTestCase.assertInstanceOf( 8395 EngineTestCase.assertInstanceOf(
8507 (obj) => obj is ClassElement, 8396 (obj) => obj is ClassElement,
8508 ClassElement, 8397 ClassElement,
8509 element); 8398 element);
8510 } 8399 }
8511 8400
8512 void test_locate_CompilationUnit() { 8401 void test_locate_CompilationUnit() {
8513 CompilationUnit cu = _resolveContents("// only comment"); 8402 CompilationUnit cu = _resolveContents("// only comment");
8514 JUnitTestCase.assertNotNull(cu.element); 8403 expect(cu.element, isNotNull);
8515 Element element = ElementLocator.locate(cu); 8404 Element element = ElementLocator.locate(cu);
8516 JUnitTestCase.assertSame(cu.element, element); 8405 expect(element, same(cu.element));
8517 } 8406 }
8518 8407
8519 void test_locate_ConstructorDeclaration() { 8408 void test_locate_ConstructorDeclaration() {
8520 AstNode id = 8409 AstNode id =
8521 _findNodeIndexedIn("bar", 0, r''' 8410 _findNodeIndexedIn("bar", 0, r'''
8522 class A { 8411 class A {
8523 A.bar() {} 8412 A.bar() {}
8524 }'''); 8413 }''');
8525 ConstructorDeclaration declaration = 8414 ConstructorDeclaration declaration =
8526 id.getAncestor((node) => node is ConstructorDeclaration); 8415 id.getAncestor((node) => node is ConstructorDeclaration);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
8685 []); 8574 []);
8686 // set ClassElement 8575 // set ClassElement
8687 ClassElement classElement = ElementFactory.classElement2("A", []); 8576 ClassElement classElement = ElementFactory.classElement2("A", []);
8688 identifier.staticElement = classElement; 8577 identifier.staticElement = classElement;
8689 // set ConstructorElement 8578 // set ConstructorElement
8690 ConstructorElement constructorElement = 8579 ConstructorElement constructorElement =
8691 ElementFactory.constructorElement2(classElement, null, []); 8580 ElementFactory.constructorElement2(classElement, null, []);
8692 creation.constructorName.staticElement = constructorElement; 8581 creation.constructorName.staticElement = constructorElement;
8693 // verify that "A" is resolved to ConstructorElement 8582 // verify that "A" is resolved to ConstructorElement
8694 Element element = ElementLocator.locate(identifier); 8583 Element element = ElementLocator.locate(identifier);
8695 JUnitTestCase.assertSame(classElement, element); 8584 expect(element, same(classElement));
8696 } 8585 }
8697 8586
8698 void test_locate_InstanceCreationExpression_type_simpleIdentifier() { 8587 void test_locate_InstanceCreationExpression_type_simpleIdentifier() {
8699 // prepare: new A() 8588 // prepare: new A()
8700 SimpleIdentifier identifier = AstFactory.identifier3("A"); 8589 SimpleIdentifier identifier = AstFactory.identifier3("A");
8701 InstanceCreationExpression creation = 8590 InstanceCreationExpression creation =
8702 AstFactory.instanceCreationExpression2( 8591 AstFactory.instanceCreationExpression2(
8703 Keyword.NEW, 8592 Keyword.NEW,
8704 AstFactory.typeName3(identifier, []), 8593 AstFactory.typeName3(identifier, []),
8705 []); 8594 []);
8706 // set ClassElement 8595 // set ClassElement
8707 ClassElement classElement = ElementFactory.classElement2("A", []); 8596 ClassElement classElement = ElementFactory.classElement2("A", []);
8708 identifier.staticElement = classElement; 8597 identifier.staticElement = classElement;
8709 // set ConstructorElement 8598 // set ConstructorElement
8710 ConstructorElement constructorElement = 8599 ConstructorElement constructorElement =
8711 ElementFactory.constructorElement2(classElement, null, []); 8600 ElementFactory.constructorElement2(classElement, null, []);
8712 creation.constructorName.staticElement = constructorElement; 8601 creation.constructorName.staticElement = constructorElement;
8713 // verify that "A" is resolved to ConstructorElement 8602 // verify that "A" is resolved to ConstructorElement
8714 Element element = ElementLocator.locate(identifier); 8603 Element element = ElementLocator.locate(identifier);
8715 JUnitTestCase.assertSame(classElement, element); 8604 expect(element, same(classElement));
8716 } 8605 }
8717 8606
8718 void test_locate_LibraryDirective() { 8607 void test_locate_LibraryDirective() {
8719 AstNode id = _findNodeIn("library", "library foo;"); 8608 AstNode id = _findNodeIn("library", "library foo;");
8720 Element element = ElementLocator.locate(id); 8609 Element element = ElementLocator.locate(id);
8721 EngineTestCase.assertInstanceOf( 8610 EngineTestCase.assertInstanceOf(
8722 (obj) => obj is LibraryElement, 8611 (obj) => obj is LibraryElement,
8723 LibraryElement, 8612 LibraryElement,
8724 element); 8613 element);
8725 } 8614 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
8813 Element element = ElementLocator.locate(id); 8702 Element element = ElementLocator.locate(id);
8814 EngineTestCase.assertInstanceOf( 8703 EngineTestCase.assertInstanceOf(
8815 (obj) => obj is LibraryElement, 8704 (obj) => obj is LibraryElement,
8816 LibraryElement, 8705 LibraryElement,
8817 element); 8706 element);
8818 } 8707 }
8819 8708
8820 void test_locate_StringLiteral_expression() { 8709 void test_locate_StringLiteral_expression() {
8821 AstNode id = _findNodeIn("abc", "var x = 'abc';"); 8710 AstNode id = _findNodeIn("abc", "var x = 'abc';");
8822 Element element = ElementLocator.locate(id); 8711 Element element = ElementLocator.locate(id);
8823 JUnitTestCase.assertNull(element); 8712 expect(element, isNull);
8824 } 8713 }
8825 8714
8826 void test_locate_StringLiteral_importUri() { 8715 void test_locate_StringLiteral_importUri() {
8827 addNamedSource("/foo.dart", "library foo; class A {}"); 8716 addNamedSource("/foo.dart", "library foo; class A {}");
8828 AstNode id = 8717 AstNode id =
8829 _findNodeIn("'foo.dart'", "import 'foo.dart'; class B extends A {}"); 8718 _findNodeIn("'foo.dart'", "import 'foo.dart'; class B extends A {}");
8830 Element element = ElementLocator.locate(id); 8719 Element element = ElementLocator.locate(id);
8831 EngineTestCase.assertInstanceOf( 8720 EngineTestCase.assertInstanceOf(
8832 (obj) => obj is LibraryElement, 8721 (obj) => obj is LibraryElement,
8833 LibraryElement, 8722 LibraryElement,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
8924 void test_visitEnumDeclaration_multiple() { 8813 void test_visitEnumDeclaration_multiple() {
8925 String firstName = "ONE"; 8814 String firstName = "ONE";
8926 String secondName = "TWO"; 8815 String secondName = "TWO";
8927 String thirdName = "THREE"; 8816 String thirdName = "THREE";
8928 EnumDeclaration enumDeclaration = 8817 EnumDeclaration enumDeclaration =
8929 AstFactory.enumDeclaration2("E", [firstName, secondName, thirdName]); 8818 AstFactory.enumDeclaration2("E", [firstName, secondName, thirdName]);
8930 ClassElement enumElement = _buildElement(enumDeclaration); 8819 ClassElement enumElement = _buildElement(enumDeclaration);
8931 List<FieldElement> fields = enumElement.fields; 8820 List<FieldElement> fields = enumElement.fields;
8932 EngineTestCase.assertLength(5, fields); 8821 EngineTestCase.assertLength(5, fields);
8933 FieldElement constant = fields[2]; 8822 FieldElement constant = fields[2];
8934 JUnitTestCase.assertNotNull(constant); 8823 expect(constant, isNotNull);
8935 JUnitTestCase.assertEquals(firstName, constant.name); 8824 expect(constant.name, firstName);
8936 JUnitTestCase.assertTrue(constant.isStatic); 8825 expect(constant.isStatic, isTrue);
8937 constant = fields[3]; 8826 constant = fields[3];
8938 JUnitTestCase.assertNotNull(constant); 8827 expect(constant, isNotNull);
8939 JUnitTestCase.assertEquals(secondName, constant.name); 8828 expect(constant.name, secondName);
8940 JUnitTestCase.assertTrue(constant.isStatic); 8829 expect(constant.isStatic, isTrue);
8941 constant = fields[4]; 8830 constant = fields[4];
8942 JUnitTestCase.assertNotNull(constant); 8831 expect(constant, isNotNull);
8943 JUnitTestCase.assertEquals(thirdName, constant.name); 8832 expect(constant.name, thirdName);
8944 JUnitTestCase.assertTrue(constant.isStatic); 8833 expect(constant.isStatic, isTrue);
8945 } 8834 }
8946 8835
8947 void test_visitEnumDeclaration_single() { 8836 void test_visitEnumDeclaration_single() {
8948 String firstName = "ONE"; 8837 String firstName = "ONE";
8949 EnumDeclaration enumDeclaration = 8838 EnumDeclaration enumDeclaration =
8950 AstFactory.enumDeclaration2("E", [firstName]); 8839 AstFactory.enumDeclaration2("E", [firstName]);
8951 ClassElement enumElement = _buildElement(enumDeclaration); 8840 ClassElement enumElement = _buildElement(enumDeclaration);
8952 List<FieldElement> fields = enumElement.fields; 8841 List<FieldElement> fields = enumElement.fields;
8953 EngineTestCase.assertLength(3, fields); 8842 EngineTestCase.assertLength(3, fields);
8954 FieldElement field = fields[0]; 8843 FieldElement field = fields[0];
8955 JUnitTestCase.assertNotNull(field); 8844 expect(field, isNotNull);
8956 JUnitTestCase.assertEquals("index", field.name); 8845 expect(field.name, "index");
8957 JUnitTestCase.assertFalse(field.isStatic); 8846 expect(field.isStatic, isFalse);
8958 JUnitTestCase.assertTrue(field.isSynthetic); 8847 expect(field.isSynthetic, isTrue);
8959 field = fields[1]; 8848 field = fields[1];
8960 JUnitTestCase.assertNotNull(field); 8849 expect(field, isNotNull);
8961 JUnitTestCase.assertEquals("values", field.name); 8850 expect(field.name, "values");
8962 JUnitTestCase.assertTrue(field.isStatic); 8851 expect(field.isStatic, isTrue);
8963 JUnitTestCase.assertTrue(field.isSynthetic); 8852 expect(field.isSynthetic, isTrue);
8964 FieldElement constant = fields[2]; 8853 FieldElement constant = fields[2];
8965 JUnitTestCase.assertNotNull(constant); 8854 expect(constant, isNotNull);
8966 JUnitTestCase.assertEquals(firstName, constant.name); 8855 expect(constant.name, firstName);
8967 JUnitTestCase.assertTrue(constant.isStatic); 8856 expect(constant.isStatic, isTrue);
8968 } 8857 }
8969 8858
8970 ClassElement _buildElement(EnumDeclaration enumDeclaration) { 8859 ClassElement _buildElement(EnumDeclaration enumDeclaration) {
8971 ElementHolder holder = new ElementHolder(); 8860 ElementHolder holder = new ElementHolder();
8972 ElementBuilder elementBuilder = new ElementBuilder(holder); 8861 ElementBuilder elementBuilder = new ElementBuilder(holder);
8973 enumDeclaration.accept(elementBuilder); 8862 enumDeclaration.accept(elementBuilder);
8974 EnumMemberBuilder memberBuilder = 8863 EnumMemberBuilder memberBuilder =
8975 new EnumMemberBuilder(new TestTypeProvider()); 8864 new EnumMemberBuilder(new TestTypeProvider());
8976 enumDeclaration.accept(memberBuilder); 8865 enumDeclaration.accept(memberBuilder);
8977 List<ClassElement> enums = holder.enums; 8866 List<ClassElement> enums = holder.enums;
(...skipping 14 matching lines...) Expand all
8992 InterfaceType createType(String fileName, String typeName) { 8881 InterfaceType createType(String fileName, String typeName) {
8993 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName); 8882 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName);
8994 ClassElementImpl element = ElementFactory.classElement2(typeName, []); 8883 ClassElementImpl element = ElementFactory.classElement2(typeName, []);
8995 unit.types = <ClassElement>[element]; 8884 unit.types = <ClassElement>[element];
8996 return element.type; 8885 return element.type;
8997 } 8886 }
8998 8887
8999 void test_creation() { 8888 void test_creation() {
9000 GatheringErrorListener listener = new GatheringErrorListener(); 8889 GatheringErrorListener listener = new GatheringErrorListener();
9001 TestSource source = new TestSource(); 8890 TestSource source = new TestSource();
9002 JUnitTestCase.assertNotNull(new ErrorReporter(listener, source)); 8891 expect(new ErrorReporter(listener, source), isNotNull);
9003 } 8892 }
9004 8893
9005 void test_reportTypeErrorForNode_differentNames() { 8894 void test_reportTypeErrorForNode_differentNames() {
9006 DartType firstType = createType("/test1.dart", "A"); 8895 DartType firstType = createType("/test1.dart", "A");
9007 DartType secondType = createType("/test2.dart", "B"); 8896 DartType secondType = createType("/test2.dart", "B");
9008 GatheringErrorListener listener = new GatheringErrorListener(); 8897 GatheringErrorListener listener = new GatheringErrorListener();
9009 ErrorReporter reporter = 8898 ErrorReporter reporter =
9010 new ErrorReporter(listener, firstType.element.source); 8899 new ErrorReporter(listener, firstType.element.source);
9011 reporter.reportTypeErrorForNode( 8900 reporter.reportTypeErrorForNode(
9012 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 8901 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
9013 AstFactory.identifier3("x"), 8902 AstFactory.identifier3("x"),
9014 [firstType, secondType]); 8903 [firstType, secondType]);
9015 AnalysisError error = listener.errors[0]; 8904 AnalysisError error = listener.errors[0];
9016 JUnitTestCase.assertTrue(error.message.indexOf("(") < 0); 8905 expect(error.message.indexOf("(") < 0, isTrue);
9017 } 8906 }
9018 8907
9019 void test_reportTypeErrorForNode_sameName() { 8908 void test_reportTypeErrorForNode_sameName() {
9020 String typeName = "A"; 8909 String typeName = "A";
9021 DartType firstType = createType("/test1.dart", typeName); 8910 DartType firstType = createType("/test1.dart", typeName);
9022 DartType secondType = createType("/test2.dart", typeName); 8911 DartType secondType = createType("/test2.dart", typeName);
9023 GatheringErrorListener listener = new GatheringErrorListener(); 8912 GatheringErrorListener listener = new GatheringErrorListener();
9024 ErrorReporter reporter = 8913 ErrorReporter reporter =
9025 new ErrorReporter(listener, firstType.element.source); 8914 new ErrorReporter(listener, firstType.element.source);
9026 reporter.reportTypeErrorForNode( 8915 reporter.reportTypeErrorForNode(
9027 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 8916 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
9028 AstFactory.identifier3("x"), 8917 AstFactory.identifier3("x"),
9029 [firstType, secondType]); 8918 [firstType, secondType]);
9030 AnalysisError error = listener.errors[0]; 8919 AnalysisError error = listener.errors[0];
9031 JUnitTestCase.assertTrue(error.message.indexOf("(") >= 0); 8920 expect(error.message.indexOf("(") >= 0, isTrue);
9032 } 8921 }
9033 } 8922 }
9034 8923
9035 8924
9036 class ErrorSeverityTest extends EngineTestCase { 8925 class ErrorSeverityTest extends EngineTestCase {
9037 void test_max_error_error() { 8926 void test_max_error_error() {
9038 JUnitTestCase.assertSame( 8927 expect(ErrorSeverity.ERROR.max(ErrorSeverity.ERROR), same(ErrorSeverity.ERRO R));
9039 ErrorSeverity.ERROR,
9040 ErrorSeverity.ERROR.max(ErrorSeverity.ERROR));
9041 } 8928 }
9042 8929
9043 void test_max_error_none() { 8930 void test_max_error_none() {
9044 JUnitTestCase.assertSame( 8931 expect(ErrorSeverity.ERROR.max(ErrorSeverity.NONE), same(ErrorSeverity.ERROR ));
9045 ErrorSeverity.ERROR,
9046 ErrorSeverity.ERROR.max(ErrorSeverity.NONE));
9047 } 8932 }
9048 8933
9049 void test_max_error_warning() { 8934 void test_max_error_warning() {
9050 JUnitTestCase.assertSame( 8935 expect(ErrorSeverity.ERROR.max(ErrorSeverity.WARNING), same(ErrorSeverity.ER ROR));
9051 ErrorSeverity.ERROR,
9052 ErrorSeverity.ERROR.max(ErrorSeverity.WARNING));
9053 } 8936 }
9054 8937
9055 void test_max_none_error() { 8938 void test_max_none_error() {
9056 JUnitTestCase.assertSame( 8939 expect(ErrorSeverity.NONE.max(ErrorSeverity.ERROR), same(ErrorSeverity.ERROR ));
9057 ErrorSeverity.ERROR,
9058 ErrorSeverity.NONE.max(ErrorSeverity.ERROR));
9059 } 8940 }
9060 8941
9061 void test_max_none_none() { 8942 void test_max_none_none() {
9062 JUnitTestCase.assertSame( 8943 expect(ErrorSeverity.NONE.max(ErrorSeverity.NONE), same(ErrorSeverity.NONE)) ;
9063 ErrorSeverity.NONE,
9064 ErrorSeverity.NONE.max(ErrorSeverity.NONE));
9065 } 8944 }
9066 8945
9067 void test_max_none_warning() { 8946 void test_max_none_warning() {
9068 JUnitTestCase.assertSame( 8947 expect(ErrorSeverity.NONE.max(ErrorSeverity.WARNING), same(ErrorSeverity.WAR NING));
9069 ErrorSeverity.WARNING,
9070 ErrorSeverity.NONE.max(ErrorSeverity.WARNING));
9071 } 8948 }
9072 8949
9073 void test_max_warning_error() { 8950 void test_max_warning_error() {
9074 JUnitTestCase.assertSame( 8951 expect(ErrorSeverity.WARNING.max(ErrorSeverity.ERROR), same(ErrorSeverity.ER ROR));
9075 ErrorSeverity.ERROR,
9076 ErrorSeverity.WARNING.max(ErrorSeverity.ERROR));
9077 } 8952 }
9078 8953
9079 void test_max_warning_none() { 8954 void test_max_warning_none() {
9080 JUnitTestCase.assertSame( 8955 expect(ErrorSeverity.WARNING.max(ErrorSeverity.NONE), same(ErrorSeverity.WAR NING));
9081 ErrorSeverity.WARNING,
9082 ErrorSeverity.WARNING.max(ErrorSeverity.NONE));
9083 } 8956 }
9084 8957
9085 void test_max_warning_warning() { 8958 void test_max_warning_warning() {
9086 JUnitTestCase.assertSame( 8959 expect(ErrorSeverity.WARNING.max(ErrorSeverity.WARNING), same(ErrorSeverity. WARNING));
9087 ErrorSeverity.WARNING,
9088 ErrorSeverity.WARNING.max(ErrorSeverity.WARNING));
9089 } 8960 }
9090 } 8961 }
9091 8962
9092 8963
9093 class ExitDetectorTest extends ParserTestCase { 8964 class ExitDetectorTest extends ParserTestCase {
9094 void fail_doStatement_continue_with_label() { 8965 void fail_doStatement_continue_with_label() {
9095 _assertFalse("{ x: do { continue x; } while(true); }"); 8966 _assertFalse("{ x: do { continue x; } while(true); }");
9096 } 8967 }
9097 8968
9098 void fail_whileStatement_continue_with_label() { 8969 void fail_whileStatement_continue_with_label() {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
9213 9084
9214 void test_conditional_ifElse_noThrow() { 9085 void test_conditional_ifElse_noThrow() {
9215 _assertFalse("c ? i : j;"); 9086 _assertFalse("c ? i : j;");
9216 } 9087 }
9217 9088
9218 void test_conditional_ifElse_thenThrow() { 9089 void test_conditional_ifElse_thenThrow() {
9219 _assertFalse("c ? throw '' : j;"); 9090 _assertFalse("c ? throw '' : j;");
9220 } 9091 }
9221 9092
9222 void test_creation() { 9093 void test_creation() {
9223 JUnitTestCase.assertNotNull(new ExitDetector()); 9094 expect(new ExitDetector(), isNotNull);
9224 } 9095 }
9225 9096
9226 void test_doStatement_throwCondition() { 9097 void test_doStatement_throwCondition() {
9227 _assertTrue("{ do {} while (throw ''); }"); 9098 _assertTrue("{ do {} while (throw ''); }");
9228 } 9099 }
9229 9100
9230 void test_doStatement_true_break() { 9101 void test_doStatement_true_break() {
9231 _assertFalse("{ do { break; } while (true); }"); 9102 _assertFalse("{ do { break; } while (true); }");
9232 } 9103 }
9233 9104
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
9563 _assertTrue("{ while (true) { throw ''; } }"); 9434 _assertTrue("{ while (true) { throw ''; } }");
9564 } 9435 }
9565 9436
9566 void _assertFalse(String source) { 9437 void _assertFalse(String source) {
9567 _assertHasReturn(false, source); 9438 _assertHasReturn(false, source);
9568 } 9439 }
9569 9440
9570 void _assertHasReturn(bool expectedResult, String source) { 9441 void _assertHasReturn(bool expectedResult, String source) {
9571 ExitDetector detector = new ExitDetector(); 9442 ExitDetector detector = new ExitDetector();
9572 Statement statement = ParserTestCase.parseStatement(source, []); 9443 Statement statement = ParserTestCase.parseStatement(source, []);
9573 JUnitTestCase.assertSame(expectedResult, statement.accept(detector)); 9444 expect(statement.accept(detector), same(expectedResult));
9574 } 9445 }
9575 9446
9576 void _assertTrue(String source) { 9447 void _assertTrue(String source) {
9577 _assertHasReturn(true, source); 9448 _assertHasReturn(true, source);
9578 } 9449 }
9579 } 9450 }
9580 9451
9581 9452
9582 class ExpressionVisitor_AngularTest_verify extends ExpressionVisitor { 9453 class ExpressionVisitor_AngularTest_verify extends ExpressionVisitor {
9583 ResolutionVerifier verifier; 9454 ResolutionVerifier verifier;
9584 9455
9585 ExpressionVisitor_AngularTest_verify(this.verifier); 9456 ExpressionVisitor_AngularTest_verify(this.verifier);
9586 9457
9587 @override 9458 @override
9588 void visitExpression(Expression expression) { 9459 void visitExpression(Expression expression) {
9589 expression.accept(verifier); 9460 expression.accept(verifier);
9590 } 9461 }
9591 } 9462 }
9592 9463
9593 9464
9594 class FileBasedSourceTest extends JUnitTestCase { 9465 class FileBasedSourceTest {
9595 void test_equals_false_differentFiles() { 9466 void test_equals_false_differentFiles() {
9596 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); 9467 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart");
9597 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); 9468 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart");
9598 FileBasedSource source1 = new FileBasedSource.con1(file1); 9469 FileBasedSource source1 = new FileBasedSource.con1(file1);
9599 FileBasedSource source2 = new FileBasedSource.con1(file2); 9470 FileBasedSource source2 = new FileBasedSource.con1(file2);
9600 JUnitTestCase.assertFalse(source1 == source2); 9471 expect(source1 == source2, isFalse);
9601 } 9472 }
9602 9473
9603 void test_equals_false_null() { 9474 void test_equals_false_null() {
9604 JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart"); 9475 JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart");
9605 FileBasedSource source1 = new FileBasedSource.con1(file); 9476 FileBasedSource source1 = new FileBasedSource.con1(file);
9606 JUnitTestCase.assertFalse(source1 == null); 9477 expect(source1 == null, isFalse);
9607 } 9478 }
9608 9479
9609 void test_equals_true() { 9480 void test_equals_true() {
9610 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart"); 9481 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
9611 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart"); 9482 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
9612 FileBasedSource source1 = new FileBasedSource.con1(file1); 9483 FileBasedSource source1 = new FileBasedSource.con1(file1);
9613 FileBasedSource source2 = new FileBasedSource.con1(file2); 9484 FileBasedSource source2 = new FileBasedSource.con1(file2);
9614 JUnitTestCase.assertTrue(source1 == source2); 9485 expect(source1 == source2, isTrue);
9615 } 9486 }
9616 9487
9617 void test_getEncoding() { 9488 void test_getEncoding() {
9618 SourceFactory factory = new SourceFactory([new FileUriResolver()]); 9489 SourceFactory factory = new SourceFactory([new FileUriResolver()]);
9619 String fullPath = "/does/not/exist.dart"; 9490 String fullPath = "/does/not/exist.dart";
9620 JavaFile file = FileUtilities2.createFile(fullPath); 9491 JavaFile file = FileUtilities2.createFile(fullPath);
9621 FileBasedSource source = new FileBasedSource.con1(file); 9492 FileBasedSource source = new FileBasedSource.con1(file);
9622 JUnitTestCase.assertEquals(source, factory.fromEncoding(source.encoding)); 9493 expect(factory.fromEncoding(source.encoding), source);
9623 } 9494 }
9624 9495
9625 void test_getFullName() { 9496 void test_getFullName() {
9626 String fullPath = "/does/not/exist.dart"; 9497 String fullPath = "/does/not/exist.dart";
9627 JavaFile file = FileUtilities2.createFile(fullPath); 9498 JavaFile file = FileUtilities2.createFile(fullPath);
9628 FileBasedSource source = new FileBasedSource.con1(file); 9499 FileBasedSource source = new FileBasedSource.con1(file);
9629 JUnitTestCase.assertEquals(file.getAbsolutePath(), source.fullName); 9500 expect(source.fullName, file.getAbsolutePath());
9630 } 9501 }
9631 9502
9632 void test_getShortName() { 9503 void test_getShortName() {
9633 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); 9504 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
9634 FileBasedSource source = new FileBasedSource.con1(file); 9505 FileBasedSource source = new FileBasedSource.con1(file);
9635 JUnitTestCase.assertEquals("exist.dart", source.shortName); 9506 expect(source.shortName, "exist.dart");
9636 } 9507 }
9637 9508
9638 void test_hashCode() { 9509 void test_hashCode() {
9639 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart"); 9510 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
9640 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart"); 9511 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
9641 FileBasedSource source1 = new FileBasedSource.con1(file1); 9512 FileBasedSource source1 = new FileBasedSource.con1(file1);
9642 FileBasedSource source2 = new FileBasedSource.con1(file2); 9513 FileBasedSource source2 = new FileBasedSource.con1(file2);
9643 JUnitTestCase.assertEquals(source1.hashCode, source2.hashCode); 9514 expect(source2.hashCode, source1.hashCode);
9644 } 9515 }
9645 9516
9646 void test_isInSystemLibrary_contagious() { 9517 void test_isInSystemLibrary_contagious() {
9647 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 9518 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
9648 JUnitTestCase.assertNotNull(sdkDirectory); 9519 expect(sdkDirectory, isNotNull);
9649 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 9520 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
9650 UriResolver resolver = new DartUriResolver(sdk); 9521 UriResolver resolver = new DartUriResolver(sdk);
9651 SourceFactory factory = new SourceFactory([resolver]); 9522 SourceFactory factory = new SourceFactory([resolver]);
9652 // resolve dart:core 9523 // resolve dart:core
9653 Source result = 9524 Source result =
9654 resolver.resolveAbsolute(parseUriWithException("dart:core")); 9525 resolver.resolveAbsolute(parseUriWithException("dart:core"));
9655 JUnitTestCase.assertNotNull(result); 9526 expect(result, isNotNull);
9656 JUnitTestCase.assertTrue(result.isInSystemLibrary); 9527 expect(result.isInSystemLibrary, isTrue);
9657 // system libraries reference only other system libraries 9528 // system libraries reference only other system libraries
9658 Source partSource = factory.resolveUri(result, "num.dart"); 9529 Source partSource = factory.resolveUri(result, "num.dart");
9659 JUnitTestCase.assertNotNull(partSource); 9530 expect(partSource, isNotNull);
9660 JUnitTestCase.assertTrue(partSource.isInSystemLibrary); 9531 expect(partSource.isInSystemLibrary, isTrue);
9661 } 9532 }
9662 9533
9663 void test_isInSystemLibrary_false() { 9534 void test_isInSystemLibrary_false() {
9664 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); 9535 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
9665 FileBasedSource source = new FileBasedSource.con1(file); 9536 FileBasedSource source = new FileBasedSource.con1(file);
9666 JUnitTestCase.assertNotNull(source); 9537 expect(source, isNotNull);
9667 JUnitTestCase.assertEquals(file.getAbsolutePath(), source.fullName); 9538 expect(source.fullName, file.getAbsolutePath());
9668 JUnitTestCase.assertFalse(source.isInSystemLibrary); 9539 expect(source.isInSystemLibrary, isFalse);
9669 } 9540 }
9670 9541
9671 void test_issue14500() { 9542 void test_issue14500() {
9672 // see https://code.google.com/p/dart/issues/detail?id=14500 9543 // see https://code.google.com/p/dart/issues/detail?id=14500
9673 FileBasedSource source = new FileBasedSource.con1( 9544 FileBasedSource source = new FileBasedSource.con1(
9674 FileUtilities2.createFile("/some/packages/foo:bar.dart")); 9545 FileUtilities2.createFile("/some/packages/foo:bar.dart"));
9675 JUnitTestCase.assertNotNull(source); 9546 expect(source, isNotNull);
9676 JUnitTestCase.assertFalse(source.exists()); 9547 expect(source.exists(), isFalse);
9677 } 9548 }
9678 9549
9679 void test_resolveRelative_dart_fileName() { 9550 void test_resolveRelative_dart_fileName() {
9680 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9551 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9681 FileBasedSource source = 9552 FileBasedSource source =
9682 new FileBasedSource.con2(parseUriWithException("dart:test"), file); 9553 new FileBasedSource.con2(parseUriWithException("dart:test"), file);
9683 JUnitTestCase.assertNotNull(source); 9554 expect(source, isNotNull);
9684 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); 9555 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart"));
9685 JUnitTestCase.assertNotNull(relative); 9556 expect(relative, isNotNull);
9686 JUnitTestCase.assertEquals("dart:test/lib.dart", relative.toString()); 9557 expect(relative.toString(), "dart:test/lib.dart");
9687 } 9558 }
9688 9559
9689 void test_resolveRelative_dart_filePath() { 9560 void test_resolveRelative_dart_filePath() {
9690 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9561 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9691 FileBasedSource source = 9562 FileBasedSource source =
9692 new FileBasedSource.con2(parseUriWithException("dart:test"), file); 9563 new FileBasedSource.con2(parseUriWithException("dart:test"), file);
9693 JUnitTestCase.assertNotNull(source); 9564 expect(source, isNotNull);
9694 Uri relative = 9565 Uri relative =
9695 source.resolveRelativeUri(parseUriWithException("c/lib.dart")); 9566 source.resolveRelativeUri(parseUriWithException("c/lib.dart"));
9696 JUnitTestCase.assertNotNull(relative); 9567 expect(relative, isNotNull);
9697 JUnitTestCase.assertEquals("dart:test/c/lib.dart", relative.toString()); 9568 expect(relative.toString(), "dart:test/c/lib.dart");
9698 } 9569 }
9699 9570
9700 void test_resolveRelative_dart_filePathWithParent() { 9571 void test_resolveRelative_dart_filePathWithParent() {
9701 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9572 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9702 FileBasedSource source = 9573 FileBasedSource source =
9703 new FileBasedSource.con2(parseUriWithException("dart:test/b/test.dart"), file); 9574 new FileBasedSource.con2(parseUriWithException("dart:test/b/test.dart"), file);
9704 JUnitTestCase.assertNotNull(source); 9575 expect(source, isNotNull);
9705 Uri relative = 9576 Uri relative =
9706 source.resolveRelativeUri(parseUriWithException("../c/lib.dart")); 9577 source.resolveRelativeUri(parseUriWithException("../c/lib.dart"));
9707 JUnitTestCase.assertNotNull(relative); 9578 expect(relative, isNotNull);
9708 JUnitTestCase.assertEquals("dart:test/c/lib.dart", relative.toString()); 9579 expect(relative.toString(), "dart:test/c/lib.dart");
9709 } 9580 }
9710 9581
9711 void test_resolveRelative_file_fileName() { 9582 void test_resolveRelative_file_fileName() {
9712 if (OSUtilities.isWindows()) { 9583 if (OSUtilities.isWindows()) {
9713 // On Windows, the URI that is produced includes a drive letter, 9584 // On Windows, the URI that is produced includes a drive letter,
9714 // which I believe is not consistent across all machines that might run 9585 // which I believe is not consistent across all machines that might run
9715 // this test. 9586 // this test.
9716 return; 9587 return;
9717 } 9588 }
9718 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9589 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9719 FileBasedSource source = new FileBasedSource.con1(file); 9590 FileBasedSource source = new FileBasedSource.con1(file);
9720 JUnitTestCase.assertNotNull(source); 9591 expect(source, isNotNull);
9721 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); 9592 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart"));
9722 JUnitTestCase.assertNotNull(relative); 9593 expect(relative, isNotNull);
9723 JUnitTestCase.assertEquals("file:///a/b/lib.dart", relative.toString()); 9594 expect(relative.toString(), "file:///a/b/lib.dart");
9724 } 9595 }
9725 9596
9726 void test_resolveRelative_file_filePath() { 9597 void test_resolveRelative_file_filePath() {
9727 if (OSUtilities.isWindows()) { 9598 if (OSUtilities.isWindows()) {
9728 // On Windows, the URI that is produced includes a drive letter, 9599 // On Windows, the URI that is produced includes a drive letter,
9729 // which I believe is not consistent across all machines that might run 9600 // which I believe is not consistent across all machines that might run
9730 // this test. 9601 // this test.
9731 return; 9602 return;
9732 } 9603 }
9733 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9604 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9734 FileBasedSource source = new FileBasedSource.con1(file); 9605 FileBasedSource source = new FileBasedSource.con1(file);
9735 JUnitTestCase.assertNotNull(source); 9606 expect(source, isNotNull);
9736 Uri relative = 9607 Uri relative =
9737 source.resolveRelativeUri(parseUriWithException("c/lib.dart")); 9608 source.resolveRelativeUri(parseUriWithException("c/lib.dart"));
9738 JUnitTestCase.assertNotNull(relative); 9609 expect(relative, isNotNull);
9739 JUnitTestCase.assertEquals("file:///a/b/c/lib.dart", relative.toString()); 9610 expect(relative.toString(), "file:///a/b/c/lib.dart");
9740 } 9611 }
9741 9612
9742 void test_resolveRelative_file_filePathWithParent() { 9613 void test_resolveRelative_file_filePathWithParent() {
9743 if (OSUtilities.isWindows()) { 9614 if (OSUtilities.isWindows()) {
9744 // On Windows, the URI that is produced includes a drive letter, which I 9615 // On Windows, the URI that is produced includes a drive letter, which I
9745 // believe is not consistent across all machines that might run this test. 9616 // believe is not consistent across all machines that might run this test.
9746 return; 9617 return;
9747 } 9618 }
9748 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9619 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9749 FileBasedSource source = new FileBasedSource.con1(file); 9620 FileBasedSource source = new FileBasedSource.con1(file);
9750 JUnitTestCase.assertNotNull(source); 9621 expect(source, isNotNull);
9751 Uri relative = 9622 Uri relative =
9752 source.resolveRelativeUri(parseUriWithException("../c/lib.dart")); 9623 source.resolveRelativeUri(parseUriWithException("../c/lib.dart"));
9753 JUnitTestCase.assertNotNull(relative); 9624 expect(relative, isNotNull);
9754 JUnitTestCase.assertEquals("file:///a/c/lib.dart", relative.toString()); 9625 expect(relative.toString(), "file:///a/c/lib.dart");
9755 } 9626 }
9756 9627
9757 void test_resolveRelative_package_fileName() { 9628 void test_resolveRelative_package_fileName() {
9758 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9629 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9759 FileBasedSource source = 9630 FileBasedSource source =
9760 new FileBasedSource.con2(parseUriWithException("package:b/test.dart"), f ile); 9631 new FileBasedSource.con2(parseUriWithException("package:b/test.dart"), f ile);
9761 JUnitTestCase.assertNotNull(source); 9632 expect(source, isNotNull);
9762 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); 9633 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart"));
9763 JUnitTestCase.assertNotNull(relative); 9634 expect(relative, isNotNull);
9764 JUnitTestCase.assertEquals("package:b/lib.dart", relative.toString()); 9635 expect(relative.toString(), "package:b/lib.dart");
9765 } 9636 }
9766 9637
9767 void test_resolveRelative_package_fileNameWithoutPackageName() { 9638 void test_resolveRelative_package_fileNameWithoutPackageName() {
9768 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9639 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9769 FileBasedSource source = 9640 FileBasedSource source =
9770 new FileBasedSource.con2(parseUriWithException("package:test.dart"), fil e); 9641 new FileBasedSource.con2(parseUriWithException("package:test.dart"), fil e);
9771 JUnitTestCase.assertNotNull(source); 9642 expect(source, isNotNull);
9772 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); 9643 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart"));
9773 JUnitTestCase.assertNotNull(relative); 9644 expect(relative, isNotNull);
9774 JUnitTestCase.assertEquals("package:lib.dart", relative.toString()); 9645 expect(relative.toString(), "package:lib.dart");
9775 } 9646 }
9776 9647
9777 void test_resolveRelative_package_filePath() { 9648 void test_resolveRelative_package_filePath() {
9778 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9649 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9779 FileBasedSource source = 9650 FileBasedSource source =
9780 new FileBasedSource.con2(parseUriWithException("package:b/test.dart"), f ile); 9651 new FileBasedSource.con2(parseUriWithException("package:b/test.dart"), f ile);
9781 JUnitTestCase.assertNotNull(source); 9652 expect(source, isNotNull);
9782 Uri relative = 9653 Uri relative =
9783 source.resolveRelativeUri(parseUriWithException("c/lib.dart")); 9654 source.resolveRelativeUri(parseUriWithException("c/lib.dart"));
9784 JUnitTestCase.assertNotNull(relative); 9655 expect(relative, isNotNull);
9785 JUnitTestCase.assertEquals("package:b/c/lib.dart", relative.toString()); 9656 expect(relative.toString(), "package:b/c/lib.dart");
9786 } 9657 }
9787 9658
9788 void test_resolveRelative_package_filePathWithParent() { 9659 void test_resolveRelative_package_filePathWithParent() {
9789 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); 9660 JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
9790 FileBasedSource source = 9661 FileBasedSource source =
9791 new FileBasedSource.con2(parseUriWithException("package:a/b/test.dart"), file); 9662 new FileBasedSource.con2(parseUriWithException("package:a/b/test.dart"), file);
9792 JUnitTestCase.assertNotNull(source); 9663 expect(source, isNotNull);
9793 Uri relative = 9664 Uri relative =
9794 source.resolveRelativeUri(parseUriWithException("../c/lib.dart")); 9665 source.resolveRelativeUri(parseUriWithException("../c/lib.dart"));
9795 JUnitTestCase.assertNotNull(relative); 9666 expect(relative, isNotNull);
9796 JUnitTestCase.assertEquals("package:a/c/lib.dart", relative.toString()); 9667 expect(relative.toString(), "package:a/c/lib.dart");
9797 } 9668 }
9798 9669
9799 void test_system() { 9670 void test_system() {
9800 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); 9671 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
9801 FileBasedSource source = 9672 FileBasedSource source =
9802 new FileBasedSource.con2(parseUriWithException("dart:core"), file); 9673 new FileBasedSource.con2(parseUriWithException("dart:core"), file);
9803 JUnitTestCase.assertNotNull(source); 9674 expect(source, isNotNull);
9804 JUnitTestCase.assertEquals(file.getAbsolutePath(), source.fullName); 9675 expect(source.fullName, file.getAbsolutePath());
9805 JUnitTestCase.assertTrue(source.isInSystemLibrary); 9676 expect(source.isInSystemLibrary, isTrue);
9806 } 9677 }
9807 } 9678 }
9808 9679
9809 9680
9810 class FileUriResolverTest extends JUnitTestCase { 9681 class FileUriResolverTest {
9811 void test_creation() { 9682 void test_creation() {
9812 JUnitTestCase.assertNotNull(new FileUriResolver()); 9683 expect(new FileUriResolver(), isNotNull);
9813 } 9684 }
9814 9685
9815 void test_resolve_file() { 9686 void test_resolve_file() {
9816 UriResolver resolver = new FileUriResolver(); 9687 UriResolver resolver = new FileUriResolver();
9817 Source result = 9688 Source result =
9818 resolver.resolveAbsolute(parseUriWithException("file:/does/not/exist.dar t")); 9689 resolver.resolveAbsolute(parseUriWithException("file:/does/not/exist.dar t"));
9819 JUnitTestCase.assertNotNull(result); 9690 expect(result, isNotNull);
9820 JUnitTestCase.assertEquals( 9691 expect(result.fullName, FileUtilities2.createFile("/does/not/exist.dart").ge tAbsolutePath());
9821 FileUtilities2.createFile("/does/not/exist.dart").getAbsolutePath(),
9822 result.fullName);
9823 } 9692 }
9824 9693
9825 void test_resolve_nonFile() { 9694 void test_resolve_nonFile() {
9826 UriResolver resolver = new FileUriResolver(); 9695 UriResolver resolver = new FileUriResolver();
9827 Source result = 9696 Source result =
9828 resolver.resolveAbsolute(parseUriWithException("dart:core")); 9697 resolver.resolveAbsolute(parseUriWithException("dart:core"));
9829 JUnitTestCase.assertNull(result); 9698 expect(result, isNull);
9830 } 9699 }
9831 } 9700 }
9832 9701
9833 9702
9834 class HtmlParserTest extends EngineTestCase { 9703 class HtmlParserTest extends EngineTestCase {
9835 /** 9704 /**
9836 * The name of the 'script' tag in an HTML file. 9705 * The name of the 'script' tag in an HTML file.
9837 */ 9706 */
9838 static String _TAG_SCRIPT = "script"; 9707 static String _TAG_SCRIPT = "script";
9839 void fail_parse_scriptWithComment() { 9708 void fail_parse_scriptWithComment() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
9874 errorListener.assertNoErrors(); 9743 errorListener.assertNoErrors();
9875 return unit; 9744 return unit;
9876 } 9745 }
9877 void test_parse_attribute() { 9746 void test_parse_attribute() {
9878 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>"); 9747 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>");
9879 _validate( 9748 _validate(
9880 htmlUnit, 9749 htmlUnit,
9881 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]); 9750 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]);
9882 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9751 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9883 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9752 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9884 JUnitTestCase.assertEquals("sdfsdf", bodyNode.attributes[0].text); 9753 expect(bodyNode.attributes[0].text, "sdfsdf");
9885 } 9754 }
9886 void test_parse_attribute_EOF() { 9755 void test_parse_attribute_EOF() {
9887 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\""); 9756 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"");
9888 _validate( 9757 _validate(
9889 htmlUnit, 9758 htmlUnit,
9890 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]); 9759 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]);
9891 } 9760 }
9892 void test_parse_attribute_EOF_missing_quote() { 9761 void test_parse_attribute_EOF_missing_quote() {
9893 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsd"); 9762 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsd");
9894 _validate( 9763 _validate(
9895 htmlUnit, 9764 htmlUnit,
9896 [_t4("html", [_t("body", _a(["foo", "\"sdfsd"]), "", [])])]); 9765 [_t4("html", [_t("body", _a(["foo", "\"sdfsd"]), "", [])])]);
9897 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9766 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9898 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9767 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9899 JUnitTestCase.assertEquals("sdfsd", bodyNode.attributes[0].text); 9768 expect(bodyNode.attributes[0].text, "sdfsd");
9900 } 9769 }
9901 void test_parse_attribute_extra_quote() { 9770 void test_parse_attribute_extra_quote() {
9902 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"\"></body></html>"); 9771 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"\"></body></html>");
9903 _validate( 9772 _validate(
9904 htmlUnit, 9773 htmlUnit,
9905 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]); 9774 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]);
9906 } 9775 }
9907 void test_parse_attribute_single_quote() { 9776 void test_parse_attribute_single_quote() {
9908 ht.HtmlUnit htmlUnit = parse("<html><body foo='sdfsdf'></body></html>"); 9777 ht.HtmlUnit htmlUnit = parse("<html><body foo='sdfsdf'></body></html>");
9909 _validate( 9778 _validate(
9910 htmlUnit, 9779 htmlUnit,
9911 [_t4("html", [_t("body", _a(["foo", "'sdfsdf'"]), "", [])])]); 9780 [_t4("html", [_t("body", _a(["foo", "'sdfsdf'"]), "", [])])]);
9912 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9781 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9913 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9782 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9914 JUnitTestCase.assertEquals("sdfsdf", bodyNode.attributes[0].text); 9783 expect(bodyNode.attributes[0].text, "sdfsdf");
9915 } 9784 }
9916 void test_parse_comment_embedded() { 9785 void test_parse_comment_embedded() {
9917 ht.HtmlUnit htmlUnit = parse("<html <!-- comment -->></html>"); 9786 ht.HtmlUnit htmlUnit = parse("<html <!-- comment -->></html>");
9918 _validate(htmlUnit, [_t3("html", "", [])]); 9787 _validate(htmlUnit, [_t3("html", "", [])]);
9919 } 9788 }
9920 void test_parse_comment_first() { 9789 void test_parse_comment_first() {
9921 ht.HtmlUnit htmlUnit = parse("<!-- comment --><html></html>"); 9790 ht.HtmlUnit htmlUnit = parse("<!-- comment --><html></html>");
9922 _validate(htmlUnit, [_t3("html", "", [])]); 9791 _validate(htmlUnit, [_t3("html", "", [])]);
9923 } 9792 }
9924 void test_parse_comment_in_content() { 9793 void test_parse_comment_in_content() {
(...skipping 23 matching lines...) Expand all
9948 _validate(htmlUnit, [_t4("html", [_t3("p", "", [])])]); 9817 _validate(htmlUnit, [_t4("html", [_t3("p", "", [])])]);
9949 } 9818 }
9950 void test_parse_directive() { 9819 void test_parse_directive() {
9951 ht.HtmlUnit htmlUnit = parse("<?xml ?>\n\n<html><p></p></html>"); 9820 ht.HtmlUnit htmlUnit = parse("<?xml ?>\n\n<html><p></p></html>");
9952 _validate(htmlUnit, [_t4("html", [_t3("p", "", [])])]); 9821 _validate(htmlUnit, [_t4("html", [_t3("p", "", [])])]);
9953 } 9822 }
9954 void test_parse_getAttribute() { 9823 void test_parse_getAttribute() {
9955 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>"); 9824 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>");
9956 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9825 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9957 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9826 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9958 JUnitTestCase.assertEquals("sdfsdf", bodyNode.getAttribute("foo").text); 9827 expect(bodyNode.getAttribute("foo").text, "sdfsdf");
9959 JUnitTestCase.assertEquals(null, bodyNode.getAttribute("bar")); 9828 expect(bodyNode.getAttribute("bar"), null);
9960 JUnitTestCase.assertEquals(null, bodyNode.getAttribute(null)); 9829 expect(bodyNode.getAttribute(null), null);
9961 } 9830 }
9962 void test_parse_getAttributeText() { 9831 void test_parse_getAttributeText() {
9963 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>"); 9832 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>");
9964 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9833 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9965 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9834 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9966 JUnitTestCase.assertEquals("sdfsdf", bodyNode.getAttributeText("foo")); 9835 expect(bodyNode.getAttributeText("foo"), "sdfsdf");
9967 JUnitTestCase.assertEquals(null, bodyNode.getAttributeText("bar")); 9836 expect(bodyNode.getAttributeText("bar"), null);
9968 JUnitTestCase.assertEquals(null, bodyNode.getAttributeText(null)); 9837 expect(bodyNode.getAttributeText(null), null);
9969 } 9838 }
9970 void test_parse_headers() { 9839 void test_parse_headers() {
9971 String code = r''' 9840 String code = r'''
9972 <html> 9841 <html>
9973 <body> 9842 <body>
9974 <h2>000</h2> 9843 <h2>000</h2>
9975 <div> 9844 <div>
9976 111 9845 111
9977 </div> 9846 </div>
9978 </body> 9847 </body>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
10023 ht.HtmlUnit unit = parse(r''' 9892 ht.HtmlUnit unit = parse(r'''
10024 <html> 9893 <html>
10025 <body> 9894 <body>
10026 <div id="x"></div> 9895 <div id="x"></div>
10027 <p class='c'></p> 9896 <p class='c'></p>
10028 <div class='c'></div> 9897 <div class='c'></div>
10029 </body> 9898 </body>
10030 </html>'''); 9899 </html>''');
10031 unit.accept(builder); 9900 unit.accept(builder);
10032 HtmlTagInfo info = builder.getTagInfo(); 9901 HtmlTagInfo info = builder.getTagInfo();
10033 JUnitTestCase.assertNotNull(info); 9902 expect(info, isNotNull);
10034 List<String> allTags = info.allTags; 9903 List<String> allTags = info.allTags;
10035 EngineTestCase.assertLength(4, allTags); 9904 EngineTestCase.assertLength(4, allTags);
10036 JUnitTestCase.assertEquals("div", info.getTagWithId("x")); 9905 expect(info.getTagWithId("x"), "div");
10037 List<String> tagsWithClass = info.getTagsWithClass("c"); 9906 List<String> tagsWithClass = info.getTagsWithClass("c");
10038 EngineTestCase.assertLength(2, tagsWithClass); 9907 EngineTestCase.assertLength(2, tagsWithClass);
10039 } 9908 }
10040 } 9909 }
10041 9910
10042 9911
10043 class HtmlUnitBuilderTest extends EngineTestCase { 9912 class HtmlUnitBuilderTest extends EngineTestCase {
10044 AnalysisContextImpl _context; 9913 AnalysisContextImpl _context;
10045 @override 9914 @override
10046 void setUp() { 9915 void setUp() {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
10118 _l(List<HtmlUnitBuilderTest_ExpectedVariable> expectedVariables) => 9987 _l(List<HtmlUnitBuilderTest_ExpectedVariable> expectedVariables) =>
10119 new HtmlUnitBuilderTest_ExpectedLibrary(this, expectedVariables); 9988 new HtmlUnitBuilderTest_ExpectedLibrary(this, expectedVariables);
10120 _ExpectedScript _s(HtmlUnitBuilderTest_ExpectedLibrary expectedLibrary) => 9989 _ExpectedScript _s(HtmlUnitBuilderTest_ExpectedLibrary expectedLibrary) =>
10121 new _ExpectedScript.con1(expectedLibrary); 9990 new _ExpectedScript.con1(expectedLibrary);
10122 _ExpectedScript _s2(String scriptSourcePath) => 9991 _ExpectedScript _s2(String scriptSourcePath) =>
10123 new _ExpectedScript.con2(scriptSourcePath); 9992 new _ExpectedScript.con2(scriptSourcePath);
10124 HtmlUnitBuilderTest_ExpectedVariable _v(String varName) => 9993 HtmlUnitBuilderTest_ExpectedVariable _v(String varName) =>
10125 new HtmlUnitBuilderTest_ExpectedVariable(varName); 9994 new HtmlUnitBuilderTest_ExpectedVariable(varName);
10126 void _validate(HtmlElementImpl element, 9995 void _validate(HtmlElementImpl element,
10127 List<_ExpectedScript> expectedScripts) { 9996 List<_ExpectedScript> expectedScripts) {
10128 JUnitTestCase.assertSame(_context, element.context); 9997 expect(element.context, same(_context));
10129 List<HtmlScriptElement> scripts = element.scripts; 9998 List<HtmlScriptElement> scripts = element.scripts;
10130 JUnitTestCase.assertNotNull(scripts); 9999 expect(scripts, isNotNull);
10131 EngineTestCase.assertLength(expectedScripts.length, scripts); 10000 EngineTestCase.assertLength(expectedScripts.length, scripts);
10132 for (int scriptIndex = 0; scriptIndex < scripts.length; scriptIndex++) { 10001 for (int scriptIndex = 0; scriptIndex < scripts.length; scriptIndex++) {
10133 expectedScripts[scriptIndex]._validate(scriptIndex, scripts[scriptIndex]); 10002 expectedScripts[scriptIndex]._validate(scriptIndex, scripts[scriptIndex]);
10134 } 10003 }
10135 } 10004 }
10136 } 10005 }
10137 10006
10138 10007
10139 class HtmlUnitBuilderTest_ExpectedLibrary { 10008 class HtmlUnitBuilderTest_ExpectedLibrary {
10140 final HtmlUnitBuilderTest HtmlUnitBuilderTest_this; 10009 final HtmlUnitBuilderTest HtmlUnitBuilderTest_this;
10141 final List<HtmlUnitBuilderTest_ExpectedVariable> _expectedVariables; 10010 final List<HtmlUnitBuilderTest_ExpectedVariable> _expectedVariables;
10142 HtmlUnitBuilderTest_ExpectedLibrary(this.HtmlUnitBuilderTest_this, 10011 HtmlUnitBuilderTest_ExpectedLibrary(this.HtmlUnitBuilderTest_this,
10143 this._expectedVariables); 10012 this._expectedVariables);
10144 void _validate(int scriptIndex, EmbeddedHtmlScriptElementImpl script) { 10013 void _validate(int scriptIndex, EmbeddedHtmlScriptElementImpl script) {
10145 LibraryElement library = script.scriptLibrary; 10014 LibraryElement library = script.scriptLibrary;
10146 JUnitTestCase.assertNotNullMsg("script $scriptIndex", library); 10015 expect(library, isNotNull, reason: "script $scriptIndex");
10147 JUnitTestCase.assertSameMsg( 10016 expect(script.context, same(HtmlUnitBuilderTest_this._context), reason: "scr ipt $scriptIndex");
10148 "script $scriptIndex",
10149 HtmlUnitBuilderTest_this._context,
10150 script.context);
10151 CompilationUnitElement unit = library.definingCompilationUnit; 10017 CompilationUnitElement unit = library.definingCompilationUnit;
10152 JUnitTestCase.assertNotNullMsg("script $scriptIndex", unit); 10018 expect(unit, isNotNull, reason: "script $scriptIndex");
10153 List<TopLevelVariableElement> variables = unit.topLevelVariables; 10019 List<TopLevelVariableElement> variables = unit.topLevelVariables;
10154 EngineTestCase.assertLength(_expectedVariables.length, variables); 10020 EngineTestCase.assertLength(_expectedVariables.length, variables);
10155 for (int index = 0; index < variables.length; index++) { 10021 for (int index = 0; index < variables.length; index++) {
10156 _expectedVariables[index].validate(scriptIndex, variables[index]); 10022 _expectedVariables[index].validate(scriptIndex, variables[index]);
10157 } 10023 }
10158 JUnitTestCase.assertSameMsg( 10024 expect(library.enclosingElement, same(script), reason: "script $scriptIndex" );
10159 "script $scriptIndex",
10160 script,
10161 library.enclosingElement);
10162 } 10025 }
10163 } 10026 }
10164 10027
10165 10028
10166 class HtmlUnitBuilderTest_ExpectedVariable { 10029 class HtmlUnitBuilderTest_ExpectedVariable {
10167 final String _expectedName; 10030 final String _expectedName;
10168 HtmlUnitBuilderTest_ExpectedVariable(this._expectedName); 10031 HtmlUnitBuilderTest_ExpectedVariable(this._expectedName);
10169 void validate(int scriptIndex, TopLevelVariableElement variable) { 10032 void validate(int scriptIndex, TopLevelVariableElement variable) {
10170 JUnitTestCase.assertNotNullMsg("script $scriptIndex", variable); 10033 expect(variable, isNotNull, reason: "script $scriptIndex");
10171 JUnitTestCase.assertEqualsMsg( 10034 expect(variable.name, _expectedName, reason: "script $scriptIndex");
10172 "script $scriptIndex",
10173 _expectedName,
10174 variable.name);
10175 } 10035 }
10176 } 10036 }
10177 10037
10178 10038
10179 /** 10039 /**
10180 * Instances of the class `HtmlWarningCodeTest` test the generation of HTML warn ing codes. 10040 * Instances of the class `HtmlWarningCodeTest` test the generation of HTML warn ing codes.
10181 */ 10041 */
10182 class HtmlWarningCodeTest extends EngineTestCase { 10042 class HtmlWarningCodeTest extends EngineTestCase {
10183 /** 10043 /**
10184 * The source factory used to create the sources to be resolved. 10044 * The source factory used to create the sources to be resolved.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
10228 _verify(r''' 10088 _verify(r'''
10229 <html> 10089 <html>
10230 <script type='application/dart' src='other.dart'/> 10090 <script type='application/dart' src='other.dart'/>
10231 </html>''', 10091 </html>''',
10232 [HtmlWarningCode.URI_DOES_NOT_EXIST]); 10092 [HtmlWarningCode.URI_DOES_NOT_EXIST]);
10233 _assertErrorLocation2(_errors[0], "other.dart"); 10093 _assertErrorLocation2(_errors[0], "other.dart");
10234 } 10094 }
10235 10095
10236 void _assertErrorLocation(AnalysisError error, int expectedOffset, 10096 void _assertErrorLocation(AnalysisError error, int expectedOffset,
10237 int expectedLength) { 10097 int expectedLength) {
10238 JUnitTestCase.assertEqualsMsg( 10098 expect(error.offset, expectedOffset, reason: error.toString());
10239 error.toString(), 10099 expect(error.length, expectedLength, reason: error.toString());
10240 expectedOffset,
10241 error.offset);
10242 JUnitTestCase.assertEqualsMsg(
10243 error.toString(),
10244 expectedLength,
10245 error.length);
10246 } 10100 }
10247 10101
10248 void _assertErrorLocation2(AnalysisError error, String expectedString) { 10102 void _assertErrorLocation2(AnalysisError error, String expectedString) {
10249 _assertErrorLocation( 10103 _assertErrorLocation(
10250 error, 10104 error,
10251 _contents.indexOf(expectedString), 10105 _contents.indexOf(expectedString),
10252 expectedString.length); 10106 expectedString.length);
10253 } 10107 }
10254 10108
10255 void _verify(String contents, List<ErrorCode> expectedErrorCodes) { 10109 void _verify(String contents, List<ErrorCode> expectedErrorCodes) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
10370 _visitNode(superConstructorInvocation); 10224 _visitNode(superConstructorInvocation);
10371 _assertNoArcs(); 10225 _assertNoArcs();
10372 } 10226 }
10373 void _assertNoArcs() { 10227 void _assertNoArcs() {
10374 Set<AstNode> tails = _referenceGraph.getTails(_head); 10228 Set<AstNode> tails = _referenceGraph.getTails(_head);
10375 EngineTestCase.assertSizeOfSet(0, tails); 10229 EngineTestCase.assertSizeOfSet(0, tails);
10376 } 10230 }
10377 void _assertOneArc(AstNode tail) { 10231 void _assertOneArc(AstNode tail) {
10378 Set<AstNode> tails = _referenceGraph.getTails(_head); 10232 Set<AstNode> tails = _referenceGraph.getTails(_head);
10379 EngineTestCase.assertSizeOfSet(1, tails); 10233 EngineTestCase.assertSizeOfSet(1, tails);
10380 JUnitTestCase.assertSame(tail, tails.first); 10234 expect(tails.first, same(tail));
10381 } 10235 }
10382 ReferenceFinder _createReferenceFinder(AstNode source) => 10236 ReferenceFinder _createReferenceFinder(AstNode source) =>
10383 new ReferenceFinder( 10237 new ReferenceFinder(
10384 source, 10238 source,
10385 _referenceGraph, 10239 _referenceGraph,
10386 _variableDeclarationMap, 10240 _variableDeclarationMap,
10387 _constructorDeclarationMap); 10241 _constructorDeclarationMap);
10388 InstanceCreationExpression _makeTailConstructor(String name, 10242 InstanceCreationExpression _makeTailConstructor(String name,
10389 bool isConstDeclaration, bool isConstUsage, bool inMap) { 10243 bool isConstDeclaration, bool isConstUsage, bool inMap) {
10390 List<ConstructorInitializer> initializers = 10244 List<ConstructorInitializer> initializers =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
10470 FileUtilities2.createFile("/libs.dart"), 10324 FileUtilities2.createFile("/libs.dart"),
10471 r''' 10325 r'''
10472 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { 10326 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
10473 'first' : const LibraryInfo( 10327 'first' : const LibraryInfo(
10474 'first/first.dart', 10328 'first/first.dart',
10475 category: 'First', 10329 category: 'First',
10476 documented: true, 10330 documented: true,
10477 platforms: VM_PLATFORM, 10331 platforms: VM_PLATFORM,
10478 dart2jsPath: 'first/first_dart2js.dart'), 10332 dart2jsPath: 'first/first_dart2js.dart'),
10479 };'''); 10333 };''');
10480 JUnitTestCase.assertNotNull(libraryMap); 10334 expect(libraryMap, isNotNull);
10481 JUnitTestCase.assertEquals(1, libraryMap.size()); 10335 expect(libraryMap.size(), 1);
10482 SdkLibrary first = libraryMap.getLibrary("dart:first"); 10336 SdkLibrary first = libraryMap.getLibrary("dart:first");
10483 JUnitTestCase.assertNotNull(first); 10337 expect(first, isNotNull);
10484 JUnitTestCase.assertEquals("First", first.category); 10338 expect(first.category, "First");
10485 JUnitTestCase.assertEquals("first/first_dart2js.dart", first.path); 10339 expect(first.path, "first/first_dart2js.dart");
10486 JUnitTestCase.assertEquals("dart:first", first.shortName); 10340 expect(first.shortName, "dart:first");
10487 JUnitTestCase.assertEquals(false, first.isDart2JsLibrary); 10341 expect(first.isDart2JsLibrary, false);
10488 JUnitTestCase.assertEquals(true, first.isDocumented); 10342 expect(first.isDocumented, true);
10489 JUnitTestCase.assertEquals(false, first.isImplementation); 10343 expect(first.isImplementation, false);
10490 JUnitTestCase.assertEquals(true, first.isVmLibrary); 10344 expect(first.isVmLibrary, true);
10491 } 10345 }
10492 void test_readFrom_empty() { 10346 void test_readFrom_empty() {
10493 LibraryMap libraryMap = new SdkLibrariesReader( 10347 LibraryMap libraryMap = new SdkLibrariesReader(
10494 false).readFromFile(FileUtilities2.createFile("/libs.dart"), ""); 10348 false).readFromFile(FileUtilities2.createFile("/libs.dart"), "");
10495 JUnitTestCase.assertNotNull(libraryMap); 10349 expect(libraryMap, isNotNull);
10496 JUnitTestCase.assertEquals(0, libraryMap.size()); 10350 expect(libraryMap.size(), 0);
10497 } 10351 }
10498 void test_readFrom_normal() { 10352 void test_readFrom_normal() {
10499 LibraryMap libraryMap = new SdkLibrariesReader( 10353 LibraryMap libraryMap = new SdkLibrariesReader(
10500 false).readFromFile( 10354 false).readFromFile(
10501 FileUtilities2.createFile("/libs.dart"), 10355 FileUtilities2.createFile("/libs.dart"),
10502 r''' 10356 r'''
10503 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { 10357 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
10504 'first' : const LibraryInfo( 10358 'first' : const LibraryInfo(
10505 'first/first.dart', 10359 'first/first.dart',
10506 category: 'First', 10360 category: 'First',
10507 documented: true, 10361 documented: true,
10508 platforms: VM_PLATFORM), 10362 platforms: VM_PLATFORM),
10509 10363
10510 'second' : const LibraryInfo( 10364 'second' : const LibraryInfo(
10511 'second/second.dart', 10365 'second/second.dart',
10512 category: 'Second', 10366 category: 'Second',
10513 documented: false, 10367 documented: false,
10514 implementation: true, 10368 implementation: true,
10515 platforms: 0), 10369 platforms: 0),
10516 };'''); 10370 };''');
10517 JUnitTestCase.assertNotNull(libraryMap); 10371 expect(libraryMap, isNotNull);
10518 JUnitTestCase.assertEquals(2, libraryMap.size()); 10372 expect(libraryMap.size(), 2);
10519 SdkLibrary first = libraryMap.getLibrary("dart:first"); 10373 SdkLibrary first = libraryMap.getLibrary("dart:first");
10520 JUnitTestCase.assertNotNull(first); 10374 expect(first, isNotNull);
10521 JUnitTestCase.assertEquals("First", first.category); 10375 expect(first.category, "First");
10522 JUnitTestCase.assertEquals("first/first.dart", first.path); 10376 expect(first.path, "first/first.dart");
10523 JUnitTestCase.assertEquals("dart:first", first.shortName); 10377 expect(first.shortName, "dart:first");
10524 JUnitTestCase.assertEquals(false, first.isDart2JsLibrary); 10378 expect(first.isDart2JsLibrary, false);
10525 JUnitTestCase.assertEquals(true, first.isDocumented); 10379 expect(first.isDocumented, true);
10526 JUnitTestCase.assertEquals(false, first.isImplementation); 10380 expect(first.isImplementation, false);
10527 JUnitTestCase.assertEquals(true, first.isVmLibrary); 10381 expect(first.isVmLibrary, true);
10528 SdkLibrary second = libraryMap.getLibrary("dart:second"); 10382 SdkLibrary second = libraryMap.getLibrary("dart:second");
10529 JUnitTestCase.assertNotNull(second); 10383 expect(second, isNotNull);
10530 JUnitTestCase.assertEquals("Second", second.category); 10384 expect(second.category, "Second");
10531 JUnitTestCase.assertEquals("second/second.dart", second.path); 10385 expect(second.path, "second/second.dart");
10532 JUnitTestCase.assertEquals("dart:second", second.shortName); 10386 expect(second.shortName, "dart:second");
10533 JUnitTestCase.assertEquals(false, second.isDart2JsLibrary); 10387 expect(second.isDart2JsLibrary, false);
10534 JUnitTestCase.assertEquals(false, second.isDocumented); 10388 expect(second.isDocumented, false);
10535 JUnitTestCase.assertEquals(true, second.isImplementation); 10389 expect(second.isImplementation, true);
10536 JUnitTestCase.assertEquals(false, second.isVmLibrary); 10390 expect(second.isVmLibrary, false);
10537 } 10391 }
10538 } 10392 }
10539 10393
10540 10394
10541 class SourceFactoryTest extends JUnitTestCase { 10395 class SourceFactoryTest {
10542 void test_creation() { 10396 void test_creation() {
10543 JUnitTestCase.assertNotNull(new SourceFactory([])); 10397 expect(new SourceFactory([]), isNotNull);
10544 } 10398 }
10545 void test_fromEncoding_invalidUri() { 10399 void test_fromEncoding_invalidUri() {
10546 SourceFactory factory = new SourceFactory([]); 10400 SourceFactory factory = new SourceFactory([]);
10547 try { 10401 try {
10548 factory.fromEncoding("<:&%>"); 10402 factory.fromEncoding("<:&%>");
10549 JUnitTestCase.fail("Expected IllegalArgumentException"); 10403 fail("Expected IllegalArgumentException");
10550 } on IllegalArgumentException catch (exception) { 10404 } on IllegalArgumentException catch (exception) {
10551 } 10405 }
10552 } 10406 }
10553 void test_fromEncoding_noResolver() { 10407 void test_fromEncoding_noResolver() {
10554 SourceFactory factory = new SourceFactory([]); 10408 SourceFactory factory = new SourceFactory([]);
10555 try { 10409 try {
10556 factory.fromEncoding("foo:/does/not/exist.dart"); 10410 factory.fromEncoding("foo:/does/not/exist.dart");
10557 JUnitTestCase.fail("Expected IllegalArgumentException"); 10411 fail("Expected IllegalArgumentException");
10558 } on IllegalArgumentException catch (exception) { 10412 } on IllegalArgumentException catch (exception) {
10559 } 10413 }
10560 } 10414 }
10561 void test_fromEncoding_valid() { 10415 void test_fromEncoding_valid() {
10562 String encoding = "file:///does/not/exist.dart"; 10416 String encoding = "file:///does/not/exist.dart";
10563 SourceFactory factory = new SourceFactory( 10417 SourceFactory factory = new SourceFactory(
10564 [new UriResolver_SourceFactoryTest_test_fromEncoding_valid(encoding)]); 10418 [new UriResolver_SourceFactoryTest_test_fromEncoding_valid(encoding)]);
10565 JUnitTestCase.assertNotNull(factory.fromEncoding(encoding)); 10419 expect(factory.fromEncoding(encoding), isNotNull);
10566 } 10420 }
10567 void test_resolveUri_absolute() { 10421 void test_resolveUri_absolute() {
10568 List<bool> invoked = [false]; 10422 List<bool> invoked = [false];
10569 SourceFactory factory = 10423 SourceFactory factory =
10570 new SourceFactory([new UriResolver_absolute(invoked)]); 10424 new SourceFactory([new UriResolver_absolute(invoked)]);
10571 factory.resolveUri(null, "dart:core"); 10425 factory.resolveUri(null, "dart:core");
10572 JUnitTestCase.assertTrue(invoked[0]); 10426 expect(invoked[0], isTrue);
10573 } 10427 }
10574 void test_resolveUri_nonAbsolute_absolute() { 10428 void test_resolveUri_nonAbsolute_absolute() {
10575 SourceFactory factory = 10429 SourceFactory factory =
10576 new SourceFactory([new UriResolver_nonAbsolute_absolute()]); 10430 new SourceFactory([new UriResolver_nonAbsolute_absolute()]);
10577 String absolutePath = "/does/not/matter.dart"; 10431 String absolutePath = "/does/not/matter.dart";
10578 Source containingSource = 10432 Source containingSource =
10579 new FileBasedSource.con1(FileUtilities2.createFile("/does/not/exist.dart ")); 10433 new FileBasedSource.con1(FileUtilities2.createFile("/does/not/exist.dart "));
10580 Source result = factory.resolveUri(containingSource, absolutePath); 10434 Source result = factory.resolveUri(containingSource, absolutePath);
10581 JUnitTestCase.assertEquals( 10435 expect(result.fullName, FileUtilities2.createFile(absolutePath).getAbsoluteP ath());
10582 FileUtilities2.createFile(absolutePath).getAbsolutePath(),
10583 result.fullName);
10584 } 10436 }
10585 void test_resolveUri_nonAbsolute_relative() { 10437 void test_resolveUri_nonAbsolute_relative() {
10586 SourceFactory factory = 10438 SourceFactory factory =
10587 new SourceFactory([new UriResolver_nonAbsolute_relative()]); 10439 new SourceFactory([new UriResolver_nonAbsolute_relative()]);
10588 Source containingSource = 10440 Source containingSource =
10589 new FileBasedSource.con1(FileUtilities2.createFile("/does/not/have.dart" )); 10441 new FileBasedSource.con1(FileUtilities2.createFile("/does/not/have.dart" ));
10590 Source result = factory.resolveUri(containingSource, "exist.dart"); 10442 Source result = factory.resolveUri(containingSource, "exist.dart");
10591 JUnitTestCase.assertEquals( 10443 expect(result.fullName, FileUtilities2.createFile("/does/not/exist.dart").ge tAbsolutePath());
10592 FileUtilities2.createFile("/does/not/exist.dart").getAbsolutePath(),
10593 result.fullName);
10594 } 10444 }
10595 void test_restoreUri() { 10445 void test_restoreUri() {
10596 JavaFile file1 = FileUtilities2.createFile("/some/file1.dart"); 10446 JavaFile file1 = FileUtilities2.createFile("/some/file1.dart");
10597 JavaFile file2 = FileUtilities2.createFile("/some/file2.dart"); 10447 JavaFile file2 = FileUtilities2.createFile("/some/file2.dart");
10598 Source source1 = new FileBasedSource.con1(file1); 10448 Source source1 = new FileBasedSource.con1(file1);
10599 Source source2 = new FileBasedSource.con1(file2); 10449 Source source2 = new FileBasedSource.con1(file2);
10600 Uri expected1 = parseUriWithException("file:///my_file.dart"); 10450 Uri expected1 = parseUriWithException("file:///my_file.dart");
10601 SourceFactory factory = 10451 SourceFactory factory =
10602 new SourceFactory([new UriResolver_restoreUri(source1, expected1)]); 10452 new SourceFactory([new UriResolver_restoreUri(source1, expected1)]);
10603 JUnitTestCase.assertSame(expected1, factory.restoreUri(source1)); 10453 expect(factory.restoreUri(source1), same(expected1));
10604 JUnitTestCase.assertSame(null, factory.restoreUri(source2)); 10454 expect(factory.restoreUri(source2), same(null));
10605 } 10455 }
10606 } 10456 }
10607 10457
10608 10458
10609 class StringScannerTest extends AbstractScannerTest { 10459 class StringScannerTest extends AbstractScannerTest {
10610 @override 10460 @override
10611 ht.AbstractScanner newScanner(String input) { 10461 ht.AbstractScanner newScanner(String input) {
10612 return new ht.StringScanner(null, input); 10462 return new ht.StringScanner(null, input);
10613 } 10463 }
10614 } 10464 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
10659 /** 10509 /**
10660 * Assert that a `ToSourceVisitor` will produce the expected source when visit ing the given 10510 * Assert that a `ToSourceVisitor` will produce the expected source when visit ing the given
10661 * node. 10511 * node.
10662 * 10512 *
10663 * @param expectedSource the source string that the visitor is expected to pro duce 10513 * @param expectedSource the source string that the visitor is expected to pro duce
10664 * @param node the AST node being visited to produce the actual source 10514 * @param node the AST node being visited to produce the actual source
10665 */ 10515 */
10666 void _assertSource(String expectedSource, ht.XmlNode node) { 10516 void _assertSource(String expectedSource, ht.XmlNode node) {
10667 PrintStringWriter writer = new PrintStringWriter(); 10517 PrintStringWriter writer = new PrintStringWriter();
10668 node.accept(new ht.ToSourceVisitor(writer)); 10518 node.accept(new ht.ToSourceVisitor(writer));
10669 JUnitTestCase.assertEquals(expectedSource, writer.toString()); 10519 expect(writer.toString(), expectedSource);
10670 } 10520 }
10671 } 10521 }
10672 10522
10673 10523
10674 class UriKindTest extends JUnitTestCase { 10524 class UriKindTest {
10675 void test_fromEncoding() { 10525 void test_fromEncoding() {
10676 JUnitTestCase.assertSame(UriKind.DART_URI, UriKind.fromEncoding(0x64)); 10526 expect(UriKind.fromEncoding(0x64), same(UriKind.DART_URI));
10677 JUnitTestCase.assertSame(UriKind.FILE_URI, UriKind.fromEncoding(0x66)); 10527 expect(UriKind.fromEncoding(0x66), same(UriKind.FILE_URI));
10678 JUnitTestCase.assertSame(UriKind.PACKAGE_URI, UriKind.fromEncoding(0x70)); 10528 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI));
10679 JUnitTestCase.assertSame(null, UriKind.fromEncoding(0x58)); 10529 expect(UriKind.fromEncoding(0x58), same(null));
10680 } 10530 }
10681 10531
10682 void test_getEncoding() { 10532 void test_getEncoding() {
10683 JUnitTestCase.assertEquals(0x64, UriKind.DART_URI.encoding); 10533 expect(UriKind.DART_URI.encoding, 0x64);
10684 JUnitTestCase.assertEquals(0x66, UriKind.FILE_URI.encoding); 10534 expect(UriKind.FILE_URI.encoding, 0x66);
10685 JUnitTestCase.assertEquals(0x70, UriKind.PACKAGE_URI.encoding); 10535 expect(UriKind.PACKAGE_URI.encoding, 0x70);
10686 } 10536 }
10687 } 10537 }
10688 10538
10689 10539
10690 class UriResolver_SourceFactoryTest_test_fromEncoding_valid extends UriResolver 10540 class UriResolver_SourceFactoryTest_test_fromEncoding_valid extends UriResolver
10691 { 10541 {
10692 String encoding; 10542 String encoding;
10693 10543
10694 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); 10544 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding);
10695 10545
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
10764 _nodeBeingEvaluated = constNode; 10614 _nodeBeingEvaluated = constNode;
10765 } 10615 }
10766 10616
10767 @override 10617 @override
10768 void beforeGetConstantInitializers(ConstructorElement constructor) { 10618 void beforeGetConstantInitializers(ConstructorElement constructor) {
10769 super.beforeGetConstantInitializers(constructor); 10619 super.beforeGetConstantInitializers(constructor);
10770 // If we are getting the constant initializers for a node in the graph, 10620 // If we are getting the constant initializers for a node in the graph,
10771 // make sure we properly recorded the dependency. 10621 // make sure we properly recorded the dependency.
10772 ConstructorDeclaration node = findConstructorDeclaration(constructor); 10622 ConstructorDeclaration node = findConstructorDeclaration(constructor);
10773 if (node != null && referenceGraph.nodes.contains(node)) { 10623 if (node != null && referenceGraph.nodes.contains(node)) {
10774 JUnitTestCase.assertTrue( 10624 expect(referenceGraph.containsPath(_nodeBeingEvaluated, node), isTrue);
10775 referenceGraph.containsPath(_nodeBeingEvaluated, node));
10776 } 10625 }
10777 } 10626 }
10778 10627
10779 @override 10628 @override
10780 void beforeGetParameterDefault(ParameterElement parameter) { 10629 void beforeGetParameterDefault(ParameterElement parameter) {
10781 super.beforeGetParameterDefault(parameter); 10630 super.beforeGetParameterDefault(parameter);
10782 // Find the ConstructorElement and figure out which 10631 // Find the ConstructorElement and figure out which
10783 // parameter we're talking about. 10632 // parameter we're talking about.
10784 ConstructorElement constructor = 10633 ConstructorElement constructor =
10785 parameter.getAncestor((element) => element is ConstructorElement); 10634 parameter.getAncestor((element) => element is ConstructorElement);
10786 int parameterIndex; 10635 int parameterIndex;
10787 List<ParameterElement> parameters = constructor.parameters; 10636 List<ParameterElement> parameters = constructor.parameters;
10788 int numParameters = parameters.length; 10637 int numParameters = parameters.length;
10789 for (parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) { 10638 for (parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) {
10790 if (identical(parameters[parameterIndex], parameter)) { 10639 if (identical(parameters[parameterIndex], parameter)) {
10791 break; 10640 break;
10792 } 10641 }
10793 } 10642 }
10794 JUnitTestCase.assertTrue(parameterIndex < numParameters); 10643 expect(parameterIndex < numParameters, isTrue);
10795 // If we are getting the default parameter for a constructor in the graph, 10644 // If we are getting the default parameter for a constructor in the graph,
10796 // make sure we properly recorded the dependency on the parameter. 10645 // make sure we properly recorded the dependency on the parameter.
10797 ConstructorDeclaration constructorNode = 10646 ConstructorDeclaration constructorNode =
10798 constructorDeclarationMap[constructor]; 10647 constructorDeclarationMap[constructor];
10799 if (constructorNode != null) { 10648 if (constructorNode != null) {
10800 FormalParameter parameterNode = 10649 FormalParameter parameterNode =
10801 constructorNode.parameters.parameters[parameterIndex]; 10650 constructorNode.parameters.parameters[parameterIndex];
10802 JUnitTestCase.assertTrue(referenceGraph.nodes.contains(parameterNode)); 10651 expect(referenceGraph.nodes.contains(parameterNode), isTrue);
10803 JUnitTestCase.assertTrue( 10652 expect(referenceGraph.containsPath(_nodeBeingEvaluated, parameterNode), is True);
10804 referenceGraph.containsPath(_nodeBeingEvaluated, parameterNode));
10805 } 10653 }
10806 } 10654 }
10807 10655
10808 @override 10656 @override
10809 ConstantVisitor createConstantVisitor(ErrorReporter errorReporter) { 10657 ConstantVisitor createConstantVisitor(ErrorReporter errorReporter) {
10810 return new ConstantValueComputerTest_ValidatingConstantVisitor( 10658 return new ConstantValueComputerTest_ValidatingConstantVisitor(
10811 typeProvider, 10659 typeProvider,
10812 referenceGraph, 10660 referenceGraph,
10813 _nodeBeingEvaluated, 10661 _nodeBeingEvaluated,
10814 errorReporter); 10662 errorReporter);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
10853 _errors.add("Expected to visit node with tag: $expectedTag"); 10701 _errors.add("Expected to visit node with tag: $expectedTag");
10854 } 10702 }
10855 if (!_errors.isEmpty) { 10703 if (!_errors.isEmpty) {
10856 StringBuffer buffer = new StringBuffer(); 10704 StringBuffer buffer = new StringBuffer();
10857 buffer.write("Invalid XML structure:"); 10705 buffer.write("Invalid XML structure:");
10858 for (String message in _errors) { 10706 for (String message in _errors) {
10859 buffer.writeln(); 10707 buffer.writeln();
10860 buffer.write(" "); 10708 buffer.write(" ");
10861 buffer.write(message); 10709 buffer.write(message);
10862 } 10710 }
10863 JUnitTestCase.fail(buffer.toString()); 10711 fail(buffer.toString());
10864 } 10712 }
10865 } 10713 }
10866 /** 10714 /**
10867 * Set the tags to be expected when visiting 10715 * Set the tags to be expected when visiting
10868 * 10716 *
10869 * @param expectedTags the expected tags 10717 * @param expectedTags the expected tags
10870 */ 10718 */
10871 void expectTags(List<XmlValidator_Tag> expectedTags) { 10719 void expectTags(List<XmlValidator_Tag> expectedTags) {
10872 // Flatten the hierarchy into expected order in which the tags are visited 10720 // Flatten the hierarchy into expected order in which the tags are visited
10873 List<XmlValidator_Tag> expected = new List<XmlValidator_Tag>(); 10721 List<XmlValidator_Tag> expected = new List<XmlValidator_Tag>();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
10933 int expectedAttributeCount = 10781 int expectedAttributeCount =
10934 _expectedAttributeKeyValuePairs.length ~/ 10782 _expectedAttributeKeyValuePairs.length ~/
10935 2; 10783 2;
10936 int actualAttributeCount = actual.attributes.length; 10784 int actualAttributeCount = actual.attributes.length;
10937 if (expectedAttributeCount != actualAttributeCount) { 10785 if (expectedAttributeCount != actualAttributeCount) {
10938 _errors.add( 10786 _errors.add(
10939 "Expected $_expectedTagsIndex tag: ${expected._tag} to have $expec tedAttributeCount attributes but found $actualAttributeCount"); 10787 "Expected $_expectedTagsIndex tag: ${expected._tag} to have $expec tedAttributeCount attributes but found $actualAttributeCount");
10940 } 10788 }
10941 _expectedAttributeIndex = 0; 10789 _expectedAttributeIndex = 0;
10942 _expectedTagsIndex++; 10790 _expectedTagsIndex++;
10943 JUnitTestCase.assertNotNull(actual.attributeEnd); 10791 expect(actual.attributeEnd, isNotNull);
10944 JUnitTestCase.assertNotNull(actual.contentEnd); 10792 expect(actual.contentEnd, isNotNull);
10945 int count = 0; 10793 int count = 0;
10946 ht.Token token = actual.attributeEnd.next; 10794 ht.Token token = actual.attributeEnd.next;
10947 ht.Token lastToken = actual.contentEnd; 10795 ht.Token lastToken = actual.contentEnd;
10948 while (!identical(token, lastToken)) { 10796 while (!identical(token, lastToken)) {
10949 token = token.next; 10797 token = token.next;
10950 if (++count > 1000) { 10798 if (++count > 1000) {
10951 JUnitTestCase.fail( 10799 fail("Expected $_expectedTagsIndex tag: ${expected._tag} to have a s equence of tokens from getAttributeEnd() to getContentEnd()");
10952 "Expected $_expectedTagsIndex tag: ${expected._tag} to have a se quence of tokens from getAttributeEnd() to getContentEnd()");
10953 break; 10800 break;
10954 } 10801 }
10955 } 10802 }
10956 if (actual.attributeEnd.type == ht.TokenType.GT) { 10803 if (actual.attributeEnd.type == ht.TokenType.GT) {
10957 if (ht.HtmlParser.SELF_CLOSING.contains(actual.tag)) { 10804 if (ht.HtmlParser.SELF_CLOSING.contains(actual.tag)) {
10958 JUnitTestCase.assertNull(actual.closingTag); 10805 expect(actual.closingTag, isNull);
10959 } else { 10806 } else {
10960 JUnitTestCase.assertNotNull(actual.closingTag); 10807 expect(actual.closingTag, isNotNull);
10961 } 10808 }
10962 } else if (actual.attributeEnd.type == ht.TokenType.SLASH_GT) { 10809 } else if (actual.attributeEnd.type == ht.TokenType.SLASH_GT) {
10963 JUnitTestCase.assertNull(actual.closingTag); 10810 expect(actual.closingTag, isNull);
10964 } else { 10811 } else {
10965 JUnitTestCase.fail( 10812 fail("Unexpected attribute end token: ${actual.attributeEnd.lexeme}");
10966 "Unexpected attribute end token: ${actual.attributeEnd.lexeme}");
10967 } 10813 }
10968 if (expected._content != null && expected._content != actual.content) { 10814 if (expected._content != null && expected._content != actual.content) {
10969 _errors.add( 10815 _errors.add(
10970 "Expected $_expectedTagsIndex tag: ${expected._tag} to have conten t '${expected._content}' but found '${actual.content}'"); 10816 "Expected $_expectedTagsIndex tag: ${expected._tag} to have conten t '${expected._content}' but found '${actual.content}'");
10971 } 10817 }
10972 if (expected._children.length != actual.tagNodes.length) { 10818 if (expected._children.length != actual.tagNodes.length) {
10973 _errors.add( 10819 _errors.add(
10974 "Expected $_expectedTagsIndex tag: ${expected._tag} to have ${expe cted._children.length} children but found ${actual.tagNodes.length}"); 10820 "Expected $_expectedTagsIndex tag: ${expected._tag} to have ${expe cted._children.length} children but found ${actual.tagNodes.length}");
10975 } else { 10821 } else {
10976 for (int index = 0; index < expected._children.length; index++) { 10822 for (int index = 0; index < expected._children.length; index++) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
11079 } 10925 }
11080 void _validate(int scriptIndex, HtmlScriptElement script) { 10926 void _validate(int scriptIndex, HtmlScriptElement script) {
11081 if (_expectedLibrary != null) { 10927 if (_expectedLibrary != null) {
11082 _validateEmbedded(scriptIndex, script); 10928 _validateEmbedded(scriptIndex, script);
11083 } else { 10929 } else {
11084 _validateExternal(scriptIndex, script); 10930 _validateExternal(scriptIndex, script);
11085 } 10931 }
11086 } 10932 }
11087 void _validateEmbedded(int scriptIndex, HtmlScriptElement script) { 10933 void _validateEmbedded(int scriptIndex, HtmlScriptElement script) {
11088 if (script is! EmbeddedHtmlScriptElementImpl) { 10934 if (script is! EmbeddedHtmlScriptElementImpl) {
11089 JUnitTestCase.fail( 10935 fail("Expected script $scriptIndex to be embedded, but found ${script != n ull ? script.runtimeType : "null"}");
11090 "Expected script $scriptIndex to be embedded, but found ${script != nu ll ? script.runtimeType : "null"}");
11091 } 10936 }
11092 EmbeddedHtmlScriptElementImpl embeddedScript = 10937 EmbeddedHtmlScriptElementImpl embeddedScript =
11093 script as EmbeddedHtmlScriptElementImpl; 10938 script as EmbeddedHtmlScriptElementImpl;
11094 _expectedLibrary._validate(scriptIndex, embeddedScript); 10939 _expectedLibrary._validate(scriptIndex, embeddedScript);
11095 } 10940 }
11096 void _validateExternal(int scriptIndex, HtmlScriptElement script) { 10941 void _validateExternal(int scriptIndex, HtmlScriptElement script) {
11097 if (script is! ExternalHtmlScriptElementImpl) { 10942 if (script is! ExternalHtmlScriptElementImpl) {
11098 JUnitTestCase.fail( 10943 fail("Expected script $scriptIndex to be external with src=$_expectedExter nalScriptName but found ${script != null ? script.runtimeType : "null"}");
11099 "Expected script $scriptIndex to be external with src=$_expectedExtern alScriptName but found ${script != null ? script.runtimeType : "null"}");
11100 } 10944 }
11101 ExternalHtmlScriptElementImpl externalScript = 10945 ExternalHtmlScriptElementImpl externalScript =
11102 script as ExternalHtmlScriptElementImpl; 10946 script as ExternalHtmlScriptElementImpl;
11103 Source scriptSource = externalScript.scriptSource; 10947 Source scriptSource = externalScript.scriptSource;
11104 if (_expectedExternalScriptName == null) { 10948 if (_expectedExternalScriptName == null) {
11105 JUnitTestCase.assertNullMsg("script $scriptIndex", scriptSource); 10949 expect(scriptSource, isNull, reason: "script $scriptIndex");
11106 } else { 10950 } else {
11107 JUnitTestCase.assertNotNullMsg("script $scriptIndex", scriptSource); 10951 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
11108 String actualExternalScriptName = scriptSource.shortName; 10952 String actualExternalScriptName = scriptSource.shortName;
11109 JUnitTestCase.assertEqualsMsg( 10953 expect(actualExternalScriptName, _expectedExternalScriptName, reason: "scr ipt $scriptIndex");
11110 "script $scriptIndex",
11111 _expectedExternalScriptName,
11112 actualExternalScriptName);
11113 } 10954 }
11114 } 10955 }
11115 } 10956 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698