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

Side by Side Diff: pkg/front_end/test/fasta/translate_uri_test.dart

Issue 2977703002: Refactorings for TranslateUri and its tests. (Closed)
Patch Set: Replace `file` with just word 'file' in documentation. Created 3 years, 5 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
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:front_end/src/fasta/translate_uri.dart'; 5 import 'package:front_end/src/fasta/translate_uri.dart';
6 import 'package:test/test.dart'; 6 import 'package:test/test.dart';
7 import 'package:test_reflective_loader/test_reflective_loader.dart'; 7 import 'package:test_reflective_loader/test_reflective_loader.dart';
8 8
9 main() { 9 main() {
10 defineReflectiveSuite(() { 10 defineReflectiveSuite(() {
11 defineReflectiveTests(TranslateUriTest); 11 defineReflectiveTests(TranslateUriTest);
12 }); 12 });
13 } 13 }
14 14
15 @reflectiveTest 15 @reflectiveTest
16 class TranslateUriTest { 16 class TranslateUriTest {
17 void test_translate_dart() { 17 void test_isPlatformImplementation() {
18 var translator = new TranslateUri({}, { 18 var translator = new TranslateUri({
19 'core': Uri.parse('file:///sdk/core/core.dart'), 19 'core': Uri.parse('file:///sdk/core/core.dart'),
20 'math': Uri.parse('file:///sdk/math/math.dart') 20 'math': Uri.parse('file:///sdk/math/math.dart')
21 }, {}); 21 }, {}, {});
22
23 bool isPlatform(String uriStr) {
24 var uri = Uri.parse(uriStr);
25 return translator.isPlatformImplementation(uri);
26 }
27
28 expect(isPlatform('dart:core/string.dart'), isTrue);
29 expect(isPlatform('dart:core'), isFalse);
30 expect(isPlatform('dart:_builtin'), isTrue);
31 expect(isPlatform('file:///sdk/math/math.dart'), isFalse);
32 }
33
34 void test_translate_dart() {
35 var translator = new TranslateUri({
36 'core': Uri.parse('file:///sdk/core/core.dart'),
37 'math': Uri.parse('file:///sdk/math/math.dart')
38 }, {}, {});
22 39
23 expect(translator.translate(Uri.parse('dart:core')), 40 expect(translator.translate(Uri.parse('dart:core')),
24 Uri.parse('file:///sdk/core/core.dart')); 41 Uri.parse('file:///sdk/core/core.dart'));
25 expect(translator.translate(Uri.parse('dart:core/string.dart')), 42 expect(translator.translate(Uri.parse('dart:core/string.dart')),
26 Uri.parse('file:///sdk/core/string.dart')); 43 Uri.parse('file:///sdk/core/string.dart'));
27 44
28 expect(translator.translate(Uri.parse('dart:math')), 45 expect(translator.translate(Uri.parse('dart:math')),
29 Uri.parse('file:///sdk/math/math.dart')); 46 Uri.parse('file:///sdk/math/math.dart'));
30
31 expect(translator.translate(Uri.parse('dart:unknown')), isNull);
32
33 expect(
34 translator.isPlatformImplementation(Uri.parse('dart:core/string.dart')),
35 isTrue);
36 expect(
37 translator.isPlatformImplementation(Uri.parse('dart:core')), isFalse);
38 expect(translator.isPlatformImplementation(Uri.parse('dart:_builtin')),
39 isTrue);
40 expect(
41 translator
42 .isPlatformImplementation(Uri.parse('file:///sdk/math/math.dart')),
43 isFalse);
44 } 47 }
45 } 48 }
OLDNEW
« pkg/front_end/lib/src/fasta/translate_uri.dart ('K') | « pkg/front_end/test/fasta/testing/suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698