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

Side by Side Diff: packages/analyzer/test/generated/sdk_test.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyzer.test.generated.sdk_test;
6
7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/sdk.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 import 'package:unittest/unittest.dart';
11
12 import '../src/context/mock_sdk.dart';
13 import '../utils.dart';
14 import 'test_support.dart';
15
16 main() {
17 initializeTestEnvironment();
18 defineReflectiveTests(DartSdkManagerTest);
19 defineReflectiveTests(SdkDescriptionTest);
20 }
21
22 @reflectiveTest
23 class DartSdkManagerTest extends EngineTestCase {
24 void test_anySdk() {
25 DartSdkManager manager =
26 new DartSdkManager('/a/b/c', false, _failIfCreated);
27 expect(manager.anySdk, isNull);
28
29 AnalysisOptions options = new AnalysisOptionsImpl();
30 SdkDescription description = new SdkDescription(<String>['/c/d'], options);
31 DartSdk sdk = new MockSdk();
32 manager.getSdk(description, () => sdk);
33 expect(manager.anySdk, same(sdk));
34 }
35
36 void test_getSdk_differentDescriptors() {
37 DartSdkManager manager =
38 new DartSdkManager('/a/b/c', false, _failIfCreated);
39 AnalysisOptions options = new AnalysisOptionsImpl();
40 SdkDescription description1 = new SdkDescription(<String>['/c/d'], options);
41 DartSdk sdk1 = new MockSdk();
42 DartSdk result1 = manager.getSdk(description1, () => sdk1);
43 expect(result1, same(sdk1));
44 SdkDescription description2 = new SdkDescription(<String>['/e/f'], options);
45 DartSdk sdk2 = new MockSdk();
46 DartSdk result2 = manager.getSdk(description2, () => sdk2);
47 expect(result2, same(sdk2));
48
49 manager.getSdk(description1, _failIfAbsent);
50 manager.getSdk(description2, _failIfAbsent);
51 }
52
53 void test_getSdk_sameDescriptor() {
54 DartSdkManager manager =
55 new DartSdkManager('/a/b/c', false, _failIfCreated);
56 AnalysisOptions options = new AnalysisOptionsImpl();
57 SdkDescription description = new SdkDescription(<String>['/c/d'], options);
58 DartSdk sdk = new MockSdk();
59 DartSdk result = manager.getSdk(description, () => sdk);
60 expect(result, same(sdk));
61 manager.getSdk(description, _failIfAbsent);
62 }
63
64 DartSdk _failIfAbsent() {
65 fail('Use of ifAbsent function');
66 return null;
67 }
68
69 DartSdk _failIfCreated(AnalysisOptions _) {
70 fail('Use of sdkCreator');
71 return null;
72 }
73 }
74
75 @reflectiveTest
76 class SdkDescriptionTest extends EngineTestCase {
77 void test_equals_differentPaths_nested() {
78 AnalysisOptions options = new AnalysisOptionsImpl();
79 SdkDescription left = new SdkDescription(<String>['/a/b/c'], options);
80 SdkDescription right = new SdkDescription(<String>['/a/b'], options);
81 expect(left == right, isFalse);
82 }
83
84 void test_equals_differentPaths_unrelated() {
85 AnalysisOptions options = new AnalysisOptionsImpl();
86 SdkDescription left = new SdkDescription(<String>['/a/b/c'], options);
87 SdkDescription right = new SdkDescription(<String>['/d/e'], options);
88 expect(left == right, isFalse);
89 }
90
91 void test_equals_noPaths() {
92 AnalysisOptions options = new AnalysisOptionsImpl();
93 SdkDescription left = new SdkDescription(<String>[], options);
94 SdkDescription right = new SdkDescription(<String>[], options);
95 expect(left == right, isTrue);
96 }
97
98 void test_equals_samePaths_differentOptions() {
99 String path = '/a/b/c';
100 AnalysisOptionsImpl leftOptions = new AnalysisOptionsImpl();
101 AnalysisOptionsImpl rightOptions = new AnalysisOptionsImpl();
102 rightOptions.strongMode = !leftOptions.strongMode;
103 SdkDescription left = new SdkDescription(<String>[path], leftOptions);
104 SdkDescription right = new SdkDescription(<String>[path], rightOptions);
105 expect(left == right, isFalse);
106 }
107
108 void test_equals_samePaths_sameOptions_multiple() {
109 String leftPath = '/a/b/c';
110 String rightPath = '/d/e';
111 AnalysisOptions options = new AnalysisOptionsImpl();
112 SdkDescription left =
113 new SdkDescription(<String>[leftPath, rightPath], options);
114 SdkDescription right =
115 new SdkDescription(<String>[leftPath, rightPath], options);
116 expect(left == right, isTrue);
117 }
118
119 void test_equals_samePaths_sameOptions_single() {
120 String path = '/a/b/c';
121 AnalysisOptions options = new AnalysisOptionsImpl();
122 SdkDescription left = new SdkDescription(<String>[path], options);
123 SdkDescription right = new SdkDescription(<String>[path], options);
124 expect(left == right, isTrue);
125 }
126 }
OLDNEW
« no previous file with comments | « packages/analyzer/test/generated/scanner_test.dart ('k') | packages/analyzer/test/generated/simple_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698