| OLD | NEW |
| 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'; |
| (...skipping 5637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5648 class ConstantVisitorTest extends ResolverTestCase { | 5648 class ConstantVisitorTest extends ResolverTestCase { |
| 5649 void test_visitConditionalExpression_false() { | 5649 void test_visitConditionalExpression_false() { |
| 5650 Expression thenExpression = AstFactory.integer(1); | 5650 Expression thenExpression = AstFactory.integer(1); |
| 5651 Expression elseExpression = AstFactory.integer(0); | 5651 Expression elseExpression = AstFactory.integer(0); |
| 5652 ConditionalExpression expression = AstFactory.conditionalExpression( | 5652 ConditionalExpression expression = AstFactory.conditionalExpression( |
| 5653 AstFactory.booleanLiteral(false), | 5653 AstFactory.booleanLiteral(false), |
| 5654 thenExpression, | 5654 thenExpression, |
| 5655 elseExpression); | 5655 elseExpression); |
| 5656 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5656 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5657 ErrorReporter errorReporter = | 5657 ErrorReporter errorReporter = |
| 5658 new ErrorReporter(errorListener, _dummySource()); | 5658 new ErrorReporterImpl(errorListener, _dummySource()); |
| 5659 _assertValue( | 5659 _assertValue( |
| 5660 0, | 5660 0, |
| 5661 expression.accept( | 5661 expression.accept( |
| 5662 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter))); | 5662 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter))); |
| 5663 errorListener.assertNoErrors(); | 5663 errorListener.assertNoErrors(); |
| 5664 } | 5664 } |
| 5665 | 5665 |
| 5666 void | 5666 void |
| 5667 test_visitConditionalExpression_instanceCreation_invalidFieldInitializer()
{ | 5667 test_visitConditionalExpression_instanceCreation_invalidFieldInitializer()
{ |
| 5668 TestTypeProvider typeProvider = new TestTypeProvider(); | 5668 TestTypeProvider typeProvider = new TestTypeProvider(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5680 constructorElement.parameters[0] = | 5680 constructorElement.parameters[0] = |
| 5681 new FieldFormalParameterElementImpl(AstFactory.identifier3("x")); | 5681 new FieldFormalParameterElementImpl(AstFactory.identifier3("x")); |
| 5682 InstanceCreationExpression expression = | 5682 InstanceCreationExpression expression = |
| 5683 AstFactory.instanceCreationExpression2( | 5683 AstFactory.instanceCreationExpression2( |
| 5684 Keyword.CONST, | 5684 Keyword.CONST, |
| 5685 AstFactory.typeName4(className, []), | 5685 AstFactory.typeName4(className, []), |
| 5686 [AstFactory.integer(0)]); | 5686 [AstFactory.integer(0)]); |
| 5687 expression.staticElement = constructorElement; | 5687 expression.staticElement = constructorElement; |
| 5688 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5688 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5689 ErrorReporter errorReporter = | 5689 ErrorReporter errorReporter = |
| 5690 new ErrorReporter(errorListener, _dummySource()); | 5690 new ErrorReporterImpl(errorListener, _dummySource()); |
| 5691 expression.accept(new ConstantVisitor.con1(typeProvider, errorReporter)); | 5691 expression.accept(new ConstantVisitor.con1(typeProvider, errorReporter)); |
| 5692 errorListener.assertErrorsWithCodes( | 5692 errorListener.assertErrorsWithCodes( |
| 5693 [CompileTimeErrorCode.INVALID_CONSTANT]); | 5693 [CompileTimeErrorCode.INVALID_CONSTANT]); |
| 5694 } | 5694 } |
| 5695 | 5695 |
| 5696 void test_visitConditionalExpression_nonBooleanCondition() { | 5696 void test_visitConditionalExpression_nonBooleanCondition() { |
| 5697 Expression thenExpression = AstFactory.integer(1); | 5697 Expression thenExpression = AstFactory.integer(1); |
| 5698 Expression elseExpression = AstFactory.integer(0); | 5698 Expression elseExpression = AstFactory.integer(0); |
| 5699 NullLiteral conditionExpression = AstFactory.nullLiteral(); | 5699 NullLiteral conditionExpression = AstFactory.nullLiteral(); |
| 5700 ConditionalExpression expression = AstFactory.conditionalExpression( | 5700 ConditionalExpression expression = AstFactory.conditionalExpression( |
| 5701 conditionExpression, | 5701 conditionExpression, |
| 5702 thenExpression, | 5702 thenExpression, |
| 5703 elseExpression); | 5703 elseExpression); |
| 5704 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5704 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5705 ErrorReporter errorReporter = | 5705 ErrorReporter errorReporter = |
| 5706 new ErrorReporter(errorListener, _dummySource()); | 5706 new ErrorReporterImpl(errorListener, _dummySource()); |
| 5707 DartObjectImpl result = expression.accept( | 5707 DartObjectImpl result = expression.accept( |
| 5708 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); | 5708 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); |
| 5709 JUnitTestCase.assertNull(result); | 5709 JUnitTestCase.assertNull(result); |
| 5710 errorListener.assertErrorsWithCodes( | 5710 errorListener.assertErrorsWithCodes( |
| 5711 [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 5711 [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 5712 } | 5712 } |
| 5713 | 5713 |
| 5714 void test_visitConditionalExpression_nonConstantElse() { | 5714 void test_visitConditionalExpression_nonConstantElse() { |
| 5715 Expression thenExpression = AstFactory.integer(1); | 5715 Expression thenExpression = AstFactory.integer(1); |
| 5716 Expression elseExpression = AstFactory.identifier3("x"); | 5716 Expression elseExpression = AstFactory.identifier3("x"); |
| 5717 ConditionalExpression expression = AstFactory.conditionalExpression( | 5717 ConditionalExpression expression = AstFactory.conditionalExpression( |
| 5718 AstFactory.booleanLiteral(true), | 5718 AstFactory.booleanLiteral(true), |
| 5719 thenExpression, | 5719 thenExpression, |
| 5720 elseExpression); | 5720 elseExpression); |
| 5721 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5721 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5722 ErrorReporter errorReporter = | 5722 ErrorReporter errorReporter = |
| 5723 new ErrorReporter(errorListener, _dummySource()); | 5723 new ErrorReporterImpl(errorListener, _dummySource()); |
| 5724 DartObjectImpl result = expression.accept( | 5724 DartObjectImpl result = expression.accept( |
| 5725 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); | 5725 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); |
| 5726 JUnitTestCase.assertNull(result); | 5726 JUnitTestCase.assertNull(result); |
| 5727 errorListener.assertErrorsWithCodes( | 5727 errorListener.assertErrorsWithCodes( |
| 5728 [CompileTimeErrorCode.INVALID_CONSTANT]); | 5728 [CompileTimeErrorCode.INVALID_CONSTANT]); |
| 5729 } | 5729 } |
| 5730 | 5730 |
| 5731 void test_visitConditionalExpression_nonConstantThen() { | 5731 void test_visitConditionalExpression_nonConstantThen() { |
| 5732 Expression thenExpression = AstFactory.identifier3("x"); | 5732 Expression thenExpression = AstFactory.identifier3("x"); |
| 5733 Expression elseExpression = AstFactory.integer(0); | 5733 Expression elseExpression = AstFactory.integer(0); |
| 5734 ConditionalExpression expression = AstFactory.conditionalExpression( | 5734 ConditionalExpression expression = AstFactory.conditionalExpression( |
| 5735 AstFactory.booleanLiteral(true), | 5735 AstFactory.booleanLiteral(true), |
| 5736 thenExpression, | 5736 thenExpression, |
| 5737 elseExpression); | 5737 elseExpression); |
| 5738 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5738 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5739 ErrorReporter errorReporter = | 5739 ErrorReporter errorReporter = |
| 5740 new ErrorReporter(errorListener, _dummySource()); | 5740 new ErrorReporterImpl(errorListener, _dummySource()); |
| 5741 DartObjectImpl result = expression.accept( | 5741 DartObjectImpl result = expression.accept( |
| 5742 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); | 5742 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)); |
| 5743 JUnitTestCase.assertNull(result); | 5743 JUnitTestCase.assertNull(result); |
| 5744 errorListener.assertErrorsWithCodes( | 5744 errorListener.assertErrorsWithCodes( |
| 5745 [CompileTimeErrorCode.INVALID_CONSTANT]); | 5745 [CompileTimeErrorCode.INVALID_CONSTANT]); |
| 5746 } | 5746 } |
| 5747 | 5747 |
| 5748 void test_visitConditionalExpression_true() { | 5748 void test_visitConditionalExpression_true() { |
| 5749 Expression thenExpression = AstFactory.integer(1); | 5749 Expression thenExpression = AstFactory.integer(1); |
| 5750 Expression elseExpression = AstFactory.integer(0); | 5750 Expression elseExpression = AstFactory.integer(0); |
| 5751 ConditionalExpression expression = AstFactory.conditionalExpression( | 5751 ConditionalExpression expression = AstFactory.conditionalExpression( |
| 5752 AstFactory.booleanLiteral(true), | 5752 AstFactory.booleanLiteral(true), |
| 5753 thenExpression, | 5753 thenExpression, |
| 5754 elseExpression); | 5754 elseExpression); |
| 5755 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5755 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5756 ErrorReporter errorReporter = | 5756 ErrorReporter errorReporter = |
| 5757 new ErrorReporter(errorListener, _dummySource()); | 5757 new ErrorReporterImpl(errorListener, _dummySource()); |
| 5758 _assertValue( | 5758 _assertValue( |
| 5759 1, | 5759 1, |
| 5760 expression.accept( | 5760 expression.accept( |
| 5761 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter))); | 5761 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter))); |
| 5762 errorListener.assertNoErrors(); | 5762 errorListener.assertNoErrors(); |
| 5763 } | 5763 } |
| 5764 | 5764 |
| 5765 void test_visitSimpleIdentifier_inEnvironment() { | 5765 void test_visitSimpleIdentifier_inEnvironment() { |
| 5766 CompilationUnit compilationUnit = | 5766 CompilationUnit compilationUnit = |
| 5767 resolveSource(EngineTestCase.createSource(["const a = b;", "const b = 3;
"])); | 5767 resolveSource(EngineTestCase.createSource(["const a = b;", "const b = 3;
"])); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5797 NonExistingSource _dummySource() { | 5797 NonExistingSource _dummySource() { |
| 5798 return new NonExistingSource("foo.dart", UriKind.FILE_URI); | 5798 return new NonExistingSource("foo.dart", UriKind.FILE_URI); |
| 5799 } | 5799 } |
| 5800 | 5800 |
| 5801 DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name, | 5801 DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name, |
| 5802 Map<String, DartObjectImpl> lexicalEnvironment) { | 5802 Map<String, DartObjectImpl> lexicalEnvironment) { |
| 5803 Source source = compilationUnit.element.source; | 5803 Source source = compilationUnit.element.source; |
| 5804 Expression expression = | 5804 Expression expression = |
| 5805 findTopLevelConstantExpression(compilationUnit, name); | 5805 findTopLevelConstantExpression(compilationUnit, name); |
| 5806 GatheringErrorListener errorListener = new GatheringErrorListener(); | 5806 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5807 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 5807 ErrorReporter errorReporter = new ErrorReporterImpl(errorListener, source); |
| 5808 DartObjectImpl result = expression.accept( | 5808 DartObjectImpl result = expression.accept( |
| 5809 new ConstantVisitor.con2(typeProvider, lexicalEnvironment, errorReporter
)); | 5809 new ConstantVisitor.con2(typeProvider, lexicalEnvironment, errorReporter
)); |
| 5810 errorListener.assertNoErrors(); | 5810 errorListener.assertNoErrors(); |
| 5811 return result; | 5811 return result; |
| 5812 } | 5812 } |
| 5813 | 5813 |
| 5814 static dartSuite() { | 5814 static dartSuite() { |
| 5815 _ut.group('ConstantVisitorTest', () { | 5815 _ut.group('ConstantVisitorTest', () { |
| 5816 _ut.test('test_visitConditionalExpression_false', () { | 5816 _ut.test('test_visitConditionalExpression_false', () { |
| 5817 final __test = new ConstantVisitorTest(); | 5817 final __test = new ConstantVisitorTest(); |
| (...skipping 5990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11808 InterfaceType createType(String fileName, String typeName) { | 11808 InterfaceType createType(String fileName, String typeName) { |
| 11809 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName); | 11809 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName); |
| 11810 ClassElementImpl element = ElementFactory.classElement2(typeName, []); | 11810 ClassElementImpl element = ElementFactory.classElement2(typeName, []); |
| 11811 unit.types = <ClassElement>[element]; | 11811 unit.types = <ClassElement>[element]; |
| 11812 return element.type; | 11812 return element.type; |
| 11813 } | 11813 } |
| 11814 | 11814 |
| 11815 void test_creation() { | 11815 void test_creation() { |
| 11816 GatheringErrorListener listener = new GatheringErrorListener(); | 11816 GatheringErrorListener listener = new GatheringErrorListener(); |
| 11817 TestSource source = new TestSource(); | 11817 TestSource source = new TestSource(); |
| 11818 JUnitTestCase.assertNotNull(new ErrorReporter(listener, source)); | 11818 JUnitTestCase.assertNotNull(new ErrorReporterImpl(listener, source)); |
| 11819 } | 11819 } |
| 11820 | 11820 |
| 11821 void test_reportTypeErrorForNode_differentNames() { | 11821 void test_reportTypeErrorForNode_differentNames() { |
| 11822 DartType firstType = createType("/test1.dart", "A"); | 11822 DartType firstType = createType("/test1.dart", "A"); |
| 11823 DartType secondType = createType("/test2.dart", "B"); | 11823 DartType secondType = createType("/test2.dart", "B"); |
| 11824 GatheringErrorListener listener = new GatheringErrorListener(); | 11824 GatheringErrorListener listener = new GatheringErrorListener(); |
| 11825 ErrorReporter reporter = | 11825 ErrorReporter reporter = |
| 11826 new ErrorReporter(listener, firstType.element.source); | 11826 new ErrorReporterImpl(listener, firstType.element.source); |
| 11827 reporter.reportTypeErrorForNode( | 11827 reporter.reportTypeErrorForNode( |
| 11828 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | 11828 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, |
| 11829 AstFactory.identifier3("x"), | 11829 AstFactory.identifier3("x"), |
| 11830 [firstType, secondType]); | 11830 [firstType, secondType]); |
| 11831 AnalysisError error = listener.errors[0]; | 11831 AnalysisError error = listener.errors[0]; |
| 11832 JUnitTestCase.assertTrue(error.message.indexOf("(") < 0); | 11832 JUnitTestCase.assertTrue(error.message.indexOf("(") < 0); |
| 11833 } | 11833 } |
| 11834 | 11834 |
| 11835 void test_reportTypeErrorForNode_sameName() { | 11835 void test_reportTypeErrorForNode_sameName() { |
| 11836 String typeName = "A"; | 11836 String typeName = "A"; |
| 11837 DartType firstType = createType("/test1.dart", typeName); | 11837 DartType firstType = createType("/test1.dart", typeName); |
| 11838 DartType secondType = createType("/test2.dart", typeName); | 11838 DartType secondType = createType("/test2.dart", typeName); |
| 11839 GatheringErrorListener listener = new GatheringErrorListener(); | 11839 GatheringErrorListener listener = new GatheringErrorListener(); |
| 11840 ErrorReporter reporter = | 11840 ErrorReporter reporter = |
| 11841 new ErrorReporter(listener, firstType.element.source); | 11841 new ErrorReporterImpl(listener, firstType.element.source); |
| 11842 reporter.reportTypeErrorForNode( | 11842 reporter.reportTypeErrorForNode( |
| 11843 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | 11843 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, |
| 11844 AstFactory.identifier3("x"), | 11844 AstFactory.identifier3("x"), |
| 11845 [firstType, secondType]); | 11845 [firstType, secondType]); |
| 11846 AnalysisError error = listener.errors[0]; | 11846 AnalysisError error = listener.errors[0]; |
| 11847 JUnitTestCase.assertTrue(error.message.indexOf("(") >= 0); | 11847 JUnitTestCase.assertTrue(error.message.indexOf("(") >= 0); |
| 11848 } | 11848 } |
| 11849 | 11849 |
| 11850 static dartSuite() { | 11850 static dartSuite() { |
| 11851 _ut.group('ErrorReporterTest', () { | 11851 _ut.group('ErrorReporterTest', () { |
| (...skipping 3203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15055 } else { | 15055 } else { |
| 15056 JUnitTestCase.assertNotNullMsg("script ${scriptIndex}", scriptSource); | 15056 JUnitTestCase.assertNotNullMsg("script ${scriptIndex}", scriptSource); |
| 15057 String actualExternalScriptName = scriptSource.shortName; | 15057 String actualExternalScriptName = scriptSource.shortName; |
| 15058 JUnitTestCase.assertEqualsMsg( | 15058 JUnitTestCase.assertEqualsMsg( |
| 15059 "script ${scriptIndex}", | 15059 "script ${scriptIndex}", |
| 15060 _expectedExternalScriptName, | 15060 _expectedExternalScriptName, |
| 15061 actualExternalScriptName); | 15061 actualExternalScriptName); |
| 15062 } | 15062 } |
| 15063 } | 15063 } |
| 15064 } | 15064 } |
| OLD | NEW |