| 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 library analyzer.test.generated.sdk_test; | 5 library analyzer.test.generated.sdk_test; | 
| 6 | 6 | 
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; | 
| 8 import 'package:analyzer/src/generated/sdk.dart'; | 8 import 'package:analyzer/src/generated/sdk.dart'; | 
| 9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; | 
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 
| 11 | 11 | 
| 12 import '../src/context/mock_sdk.dart'; | 12 import '../src/context/mock_sdk.dart'; | 
| 13 import 'test_support.dart'; | 13 import 'test_support.dart'; | 
| 14 | 14 | 
| 15 main() { | 15 main() { | 
| 16   defineReflectiveSuite(() { | 16   defineReflectiveSuite(() { | 
| 17     defineReflectiveTests(DartSdkManagerTest); | 17     defineReflectiveTests(DartSdkManagerTest); | 
| 18     defineReflectiveTests(SdkDescriptionTest); | 18     defineReflectiveTests(SdkDescriptionTest); | 
| 19   }); | 19   }); | 
| 20 } | 20 } | 
| 21 | 21 | 
| 22 @reflectiveTest | 22 @reflectiveTest | 
| 23 class DartSdkManagerTest extends EngineTestCase { | 23 class DartSdkManagerTest extends EngineTestCase { | 
| 24   void test_anySdk() { | 24   void test_anySdk() { | 
| 25     DartSdkManager manager = | 25     DartSdkManager manager = new DartSdkManager('/a/b/c', false); | 
| 26         new DartSdkManager('/a/b/c', false, _failIfCreated); |  | 
| 27     expect(manager.anySdk, isNull); | 26     expect(manager.anySdk, isNull); | 
| 28 | 27 | 
| 29     AnalysisOptions options = new AnalysisOptionsImpl(); | 28     AnalysisOptions options = new AnalysisOptionsImpl(); | 
| 30     SdkDescription description = new SdkDescription(<String>['/c/d'], options); | 29     SdkDescription description = new SdkDescription(<String>['/c/d'], options); | 
| 31     DartSdk sdk = new MockSdk(); | 30     DartSdk sdk = new MockSdk(); | 
| 32     manager.getSdk(description, () => sdk); | 31     manager.getSdk(description, () => sdk); | 
| 33     expect(manager.anySdk, same(sdk)); | 32     expect(manager.anySdk, same(sdk)); | 
| 34   } | 33   } | 
| 35 | 34 | 
| 36   void test_getSdk_differentDescriptors() { | 35   void test_getSdk_differentDescriptors() { | 
| 37     DartSdkManager manager = | 36     DartSdkManager manager = new DartSdkManager('/a/b/c', false); | 
| 38         new DartSdkManager('/a/b/c', false, _failIfCreated); |  | 
| 39     AnalysisOptions options = new AnalysisOptionsImpl(); | 37     AnalysisOptions options = new AnalysisOptionsImpl(); | 
| 40     SdkDescription description1 = new SdkDescription(<String>['/c/d'], options); | 38     SdkDescription description1 = new SdkDescription(<String>['/c/d'], options); | 
| 41     DartSdk sdk1 = new MockSdk(); | 39     DartSdk sdk1 = new MockSdk(); | 
| 42     DartSdk result1 = manager.getSdk(description1, () => sdk1); | 40     DartSdk result1 = manager.getSdk(description1, () => sdk1); | 
| 43     expect(result1, same(sdk1)); | 41     expect(result1, same(sdk1)); | 
| 44     SdkDescription description2 = new SdkDescription(<String>['/e/f'], options); | 42     SdkDescription description2 = new SdkDescription(<String>['/e/f'], options); | 
| 45     DartSdk sdk2 = new MockSdk(); | 43     DartSdk sdk2 = new MockSdk(); | 
| 46     DartSdk result2 = manager.getSdk(description2, () => sdk2); | 44     DartSdk result2 = manager.getSdk(description2, () => sdk2); | 
| 47     expect(result2, same(sdk2)); | 45     expect(result2, same(sdk2)); | 
| 48 | 46 | 
| 49     manager.getSdk(description1, _failIfAbsent); | 47     manager.getSdk(description1, _failIfAbsent); | 
| 50     manager.getSdk(description2, _failIfAbsent); | 48     manager.getSdk(description2, _failIfAbsent); | 
| 51   } | 49   } | 
| 52 | 50 | 
| 53   void test_getSdk_sameDescriptor() { | 51   void test_getSdk_sameDescriptor() { | 
| 54     DartSdkManager manager = | 52     DartSdkManager manager = new DartSdkManager('/a/b/c', false); | 
| 55         new DartSdkManager('/a/b/c', false, _failIfCreated); |  | 
| 56     AnalysisOptions options = new AnalysisOptionsImpl(); | 53     AnalysisOptions options = new AnalysisOptionsImpl(); | 
| 57     SdkDescription description = new SdkDescription(<String>['/c/d'], options); | 54     SdkDescription description = new SdkDescription(<String>['/c/d'], options); | 
| 58     DartSdk sdk = new MockSdk(); | 55     DartSdk sdk = new MockSdk(); | 
| 59     DartSdk result = manager.getSdk(description, () => sdk); | 56     DartSdk result = manager.getSdk(description, () => sdk); | 
| 60     expect(result, same(sdk)); | 57     expect(result, same(sdk)); | 
| 61     manager.getSdk(description, _failIfAbsent); | 58     manager.getSdk(description, _failIfAbsent); | 
| 62   } | 59   } | 
| 63 | 60 | 
| 64   DartSdk _failIfAbsent() { | 61   DartSdk _failIfAbsent() { | 
| 65     fail('Use of ifAbsent function'); | 62     fail('Use of ifAbsent function'); | 
| 66     return null; | 63     return null; | 
| 67   } | 64   } | 
| 68 |  | 
| 69   DartSdk _failIfCreated(AnalysisOptions _) { |  | 
| 70     fail('Use of sdkCreator'); |  | 
| 71     return null; |  | 
| 72   } |  | 
| 73 } | 65 } | 
| 74 | 66 | 
| 75 @reflectiveTest | 67 @reflectiveTest | 
| 76 class SdkDescriptionTest extends EngineTestCase { | 68 class SdkDescriptionTest extends EngineTestCase { | 
| 77   void test_equals_differentPaths_nested() { | 69   void test_equals_differentPaths_nested() { | 
| 78     AnalysisOptions options = new AnalysisOptionsImpl(); | 70     AnalysisOptions options = new AnalysisOptionsImpl(); | 
| 79     SdkDescription left = new SdkDescription(<String>['/a/b/c'], options); | 71     SdkDescription left = new SdkDescription(<String>['/a/b/c'], options); | 
| 80     SdkDescription right = new SdkDescription(<String>['/a/b'], options); | 72     SdkDescription right = new SdkDescription(<String>['/a/b'], options); | 
| 81     expect(left == right, isFalse); | 73     expect(left == right, isFalse); | 
| 82   } | 74   } | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 117   } | 109   } | 
| 118 | 110 | 
| 119   void test_equals_samePaths_sameOptions_single() { | 111   void test_equals_samePaths_sameOptions_single() { | 
| 120     String path = '/a/b/c'; | 112     String path = '/a/b/c'; | 
| 121     AnalysisOptions options = new AnalysisOptionsImpl(); | 113     AnalysisOptions options = new AnalysisOptionsImpl(); | 
| 122     SdkDescription left = new SdkDescription(<String>[path], options); | 114     SdkDescription left = new SdkDescription(<String>[path], options); | 
| 123     SdkDescription right = new SdkDescription(<String>[path], options); | 115     SdkDescription right = new SdkDescription(<String>[path], options); | 
| 124     expect(left == right, isTrue); | 116     expect(left == right, isTrue); | 
| 125   } | 117   } | 
| 126 } | 118 } | 
| OLD | NEW | 
|---|