| 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 3788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3799 " const A() : x = 5;", | 3799 " const A() : x = 5;", |
| 3800 " final int x;", | 3800 " final int x;", |
| 3801 "}", | 3801 "}", |
| 3802 "class B extends A {", | 3802 "class B extends A {", |
| 3803 " const B();", | 3803 " const B();", |
| 3804 "}", | 3804 "}", |
| 3805 "const B b = const B();"]), | 3805 "const B b = const B();"]), |
| 3806 []); | 3806 []); |
| 3807 } | 3807 } |
| 3808 | 3808 |
| 3809 void test_dependencyOnNonFactoryRedirect() { |
| 3810 // a depends on A.foo() depends on A.bar() |
| 3811 _assertProperDependencies( |
| 3812 EngineTestCase.createSource( |
| 3813 [ |
| 3814 "const A a = const A.foo();", |
| 3815 "class A {", |
| 3816 " const A.foo() : this.bar();", |
| 3817 " const A.bar();", |
| 3818 "}"]), |
| 3819 []); |
| 3820 } |
| 3821 |
| 3822 void test_dependencyOnNonFactoryRedirect_arg() { |
| 3823 // a depends on A.foo() depends on b |
| 3824 _assertProperDependencies( |
| 3825 EngineTestCase.createSource( |
| 3826 [ |
| 3827 "const A a = const A.foo();", |
| 3828 "const int b = 1;", |
| 3829 "class A {", |
| 3830 " const A.foo() : this.bar(b);", |
| 3831 " const A.bar(x) : y = x;", |
| 3832 " final int y;" |
| 3833 "}"]), |
| 3834 []); |
| 3835 } |
| 3836 |
| 3837 void test_dependencyOnNonFactoryRedirect_defaultValue() { |
| 3838 // a depends on A.foo() depends on A.bar() depends on b |
| 3839 _assertProperDependencies( |
| 3840 EngineTestCase.createSource( |
| 3841 [ |
| 3842 "const A a = const A.foo();", |
| 3843 "const int b = 1;", |
| 3844 "class A {", |
| 3845 " const A.foo() : this.bar();", |
| 3846 " const A.bar([x = b]) : y = x;", |
| 3847 " final int y;", |
| 3848 "}"]), |
| 3849 []); |
| 3850 } |
| 3851 |
| 3852 void test_dependencyOnNonFactoryRedirect_toMissing() { |
| 3853 // a depends on A.foo() which depends on nothing, since A.bar() is |
| 3854 // missing. |
| 3855 _assertProperDependencies( |
| 3856 EngineTestCase.createSource( |
| 3857 [ |
| 3858 "const A a = const A.foo();", |
| 3859 "class A {", |
| 3860 " const A.foo() : this.bar();", |
| 3861 "}"]), |
| 3862 [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]); |
| 3863 } |
| 3864 |
| 3865 void test_dependencyOnNonFactoryRedirect_toNonConst() { |
| 3866 // a depends on A.foo() which depends on nothing, since A.bar() is |
| 3867 // non-const. |
| 3868 _assertProperDependencies( |
| 3869 EngineTestCase.createSource( |
| 3870 [ |
| 3871 "const A a = const A.foo();", |
| 3872 "class A {", |
| 3873 " const A.foo() : this.bar();", |
| 3874 " A.bar();", |
| 3875 "}"]), |
| 3876 []); |
| 3877 } |
| 3878 |
| 3879 void test_dependencyOnNonFactoryRedirect_unnamed() { |
| 3880 // a depends on A.foo() depends on A() |
| 3881 _assertProperDependencies( |
| 3882 EngineTestCase.createSource( |
| 3883 [ |
| 3884 "const A a = const A.foo();", |
| 3885 "class A {", |
| 3886 " const A.foo() : this();", |
| 3887 " const A();", |
| 3888 "}"]), |
| 3889 []); |
| 3890 } |
| 3891 |
| 3809 void test_dependencyOnOptionalParameterDefault() { | 3892 void test_dependencyOnOptionalParameterDefault() { |
| 3810 // a depends on A() depends on B() | 3893 // a depends on A() depends on B() |
| 3811 _assertProperDependencies( | 3894 _assertProperDependencies( |
| 3812 EngineTestCase.createSource( | 3895 EngineTestCase.createSource( |
| 3813 [ | 3896 [ |
| 3814 "class A {", | 3897 "class A {", |
| 3815 " const A([x = const B()]) : b = x;", | 3898 " const A([x = const B()]) : b = x;", |
| 3816 " final B b;", | 3899 " final B b;", |
| 3817 "}", | 3900 "}", |
| 3818 "class B {", | 3901 "class B {", |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4119 _evaluateInstanceCreationExpression(compilationUnit, "foo"); | 4202 _evaluateInstanceCreationExpression(compilationUnit, "foo"); |
| 4120 Map<String, DartObjectImpl> fields = _assertType(result, "B"); | 4203 Map<String, DartObjectImpl> fields = _assertType(result, "B"); |
| 4121 EngineTestCase.assertSizeOfMap(2, fields); | 4204 EngineTestCase.assertSizeOfMap(2, fields); |
| 4122 _assertIntField(fields, "y", 4); | 4205 _assertIntField(fields, "y", 4); |
| 4123 Map<String, DartObjectImpl> superclassFields = | 4206 Map<String, DartObjectImpl> superclassFields = |
| 4124 _assertFieldType(fields, GenericState.SUPERCLASS_FIELD, "A"); | 4207 _assertFieldType(fields, GenericState.SUPERCLASS_FIELD, "A"); |
| 4125 EngineTestCase.assertSizeOfMap(1, superclassFields); | 4208 EngineTestCase.assertSizeOfMap(1, superclassFields); |
| 4126 _assertIntField(superclassFields, "x", 3); | 4209 _assertIntField(superclassFields, "x", 3); |
| 4127 } | 4210 } |
| 4128 | 4211 |
| 4212 void test_instanceCreationExpression_nonFactoryRedirect() { |
| 4213 CompilationUnit compilationUnit = resolveSource( |
| 4214 EngineTestCase.createSource( |
| 4215 [ |
| 4216 "const foo = const A.a1();", |
| 4217 "class A {", |
| 4218 " const A.a1() : this.a2();", |
| 4219 " const A.a2() : x = 5;", |
| 4220 " final int x;", |
| 4221 "}"])); |
| 4222 Map<String, DartObjectImpl> aFields = _assertType( |
| 4223 _evaluateInstanceCreationExpression(compilationUnit, "foo"), |
| 4224 "A"); |
| 4225 _assertIntField(aFields, 'x', 5); |
| 4226 } |
| 4227 |
| 4228 void test_instanceCreationExpression_nonFactoryRedirect_arg() { |
| 4229 CompilationUnit compilationUnit = resolveSource( |
| 4230 EngineTestCase.createSource( |
| 4231 [ |
| 4232 "const foo = const A.a1(1);", |
| 4233 "class A {", |
| 4234 " const A.a1(x) : this.a2(x + 100);", |
| 4235 " const A.a2(x) : y = x + 10;", |
| 4236 " final int y;", |
| 4237 "}"])); |
| 4238 Map<String, DartObjectImpl> aFields = _assertType( |
| 4239 _evaluateInstanceCreationExpression(compilationUnit, "foo"), |
| 4240 "A"); |
| 4241 _assertIntField(aFields, 'y', 111); |
| 4242 } |
| 4243 |
| 4244 void test_instanceCreationExpression_nonFactoryRedirect_cycle() { |
| 4245 // It is an error to have a cycle in non-factory redirects; however, we |
| 4246 // need to make sure that even if the error occurs, attempting to evaluate |
| 4247 // the constant will terminate. |
| 4248 CompilationUnit compilationUnit = resolveSource( |
| 4249 EngineTestCase.createSource( |
| 4250 [ |
| 4251 "const foo = const A();", |
| 4252 "class A {", |
| 4253 " const A() : this.b();", |
| 4254 " const A.b() : this();", |
| 4255 "}"])); |
| 4256 _assertValidUnknown( |
| 4257 _evaluateInstanceCreationExpression(compilationUnit, "foo")); |
| 4258 } |
| 4259 |
| 4260 void test_instanceCreationExpression_nonFactoryRedirect_defaultArg() { |
| 4261 CompilationUnit compilationUnit = resolveSource( |
| 4262 EngineTestCase.createSource( |
| 4263 [ |
| 4264 "const foo = const A.a1();", |
| 4265 "class A {", |
| 4266 " const A.a1() : this.a2();", |
| 4267 " const A.a2([x = 100]) : y = x + 10;", |
| 4268 " final int y;", |
| 4269 "}"])); |
| 4270 Map<String, DartObjectImpl> aFields = _assertType( |
| 4271 _evaluateInstanceCreationExpression(compilationUnit, "foo"), |
| 4272 "A"); |
| 4273 _assertIntField(aFields, 'y', 110); |
| 4274 } |
| 4275 |
| 4276 void test_instanceCreationExpression_nonFactoryRedirect_toMissing() { |
| 4277 CompilationUnit compilationUnit = resolveSource( |
| 4278 EngineTestCase.createSource( |
| 4279 [ |
| 4280 "const foo = const A.a1();", |
| 4281 "class A {", |
| 4282 " const A.a1() : this.a2();", |
| 4283 "}"])); |
| 4284 // We don't care what value foo evaluates to (since there is a compile |
| 4285 // error), but we shouldn't crash, and we should figure |
| 4286 // out that it evaluates to an instance of class A. |
| 4287 _assertType( |
| 4288 _evaluateInstanceCreationExpression(compilationUnit, "foo"), |
| 4289 "A"); |
| 4290 } |
| 4291 |
| 4292 void test_instanceCreationExpression_nonFactoryRedirect_toNonConst() { |
| 4293 CompilationUnit compilationUnit = resolveSource( |
| 4294 EngineTestCase.createSource( |
| 4295 [ |
| 4296 "const foo = const A.a1();", |
| 4297 "class A {", |
| 4298 " const A.a1() : this.a2();", |
| 4299 " A.a2();", |
| 4300 "}"])); |
| 4301 // We don't care what value foo evaluates to (since there is a compile |
| 4302 // error), but we shouldn't crash, and we should figure |
| 4303 // out that it evaluates to an instance of class A. |
| 4304 _assertType( |
| 4305 _evaluateInstanceCreationExpression(compilationUnit, "foo"), |
| 4306 "A"); |
| 4307 } |
| 4308 |
| 4309 void test_instanceCreationExpression_nonFactoryRedirect_unnamed() { |
| 4310 CompilationUnit compilationUnit = resolveSource( |
| 4311 EngineTestCase.createSource( |
| 4312 [ |
| 4313 "const foo = const A.a1();", |
| 4314 "class A {", |
| 4315 " const A.a1() : this();", |
| 4316 " const A() : x = 5;", |
| 4317 " final int x;", |
| 4318 "}"])); |
| 4319 Map<String, DartObjectImpl> aFields = _assertType( |
| 4320 _evaluateInstanceCreationExpression(compilationUnit, "foo"), |
| 4321 "A"); |
| 4322 _assertIntField(aFields, 'x', 5); |
| 4323 } |
| 4324 |
| 4129 void test_instanceCreationExpression_redirect() { | 4325 void test_instanceCreationExpression_redirect() { |
| 4130 CompilationUnit compilationUnit = resolveSource( | 4326 CompilationUnit compilationUnit = resolveSource( |
| 4131 EngineTestCase.createSource( | 4327 EngineTestCase.createSource( |
| 4132 [ | 4328 [ |
| 4133 "const foo = const A();", | 4329 "const foo = const A();", |
| 4134 "class A {", | 4330 "class A {", |
| 4135 " const factory A() = B;", | 4331 " const factory A() = B;", |
| 4136 "}", | 4332 "}", |
| 4137 "class B implements A {", | 4333 "class B implements A {", |
| 4138 " const B();", | 4334 " const B();", |
| (...skipping 6835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10974 } else { | 11170 } else { |
| 10975 JUnitTestCase.assertNotNullMsg("script ${scriptIndex}", scriptSource); | 11171 JUnitTestCase.assertNotNullMsg("script ${scriptIndex}", scriptSource); |
| 10976 String actualExternalScriptName = scriptSource.shortName; | 11172 String actualExternalScriptName = scriptSource.shortName; |
| 10977 JUnitTestCase.assertEqualsMsg( | 11173 JUnitTestCase.assertEqualsMsg( |
| 10978 "script ${scriptIndex}", | 11174 "script ${scriptIndex}", |
| 10979 _expectedExternalScriptName, | 11175 _expectedExternalScriptName, |
| 10980 actualExternalScriptName); | 11176 actualExternalScriptName); |
| 10981 } | 11177 } |
| 10982 } | 11178 } |
| 10983 } | 11179 } |
| OLD | NEW |