OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:unittest/src/backend/operating_system.dart'; | 10 import 'package:test/src/backend/operating_system.dart'; |
11 import 'package:unittest/src/backend/platform_selector.dart'; | 11 import 'package:test/src/backend/platform_selector.dart'; |
12 import 'package:unittest/src/backend/test_platform.dart'; | 12 import 'package:test/src/backend/test_platform.dart'; |
13 | 13 |
14 void main() { | 14 void main() { |
15 test("new PlatformSelector.parse() disallows invalid variables", () { | 15 test("new PlatformSelector.parse() disallows invalid variables", () { |
16 expect(() => new PlatformSelector.parse("undefined"), | 16 expect(() => new PlatformSelector.parse("undefined"), |
17 throwsFormatException); | 17 throwsFormatException); |
18 }); | 18 }); |
19 | 19 |
20 group("operator:", () { | 20 group("operator:", () { |
21 test("conditional", () { | 21 test("conditional", () { |
22 _expectEval("vm ? vm : browser", true); | 22 _expectEval("vm ? vm : browser", true); |
(...skipping 110 matching lines...) Loading... |
133 /// Returns the result of evaluating [expression] on [platform] and [os]. | 133 /// Returns the result of evaluating [expression] on [platform] and [os]. |
134 /// | 134 /// |
135 /// [platform] defaults to [TestPlatform.vm]; [os] defaults to the current | 135 /// [platform] defaults to [TestPlatform.vm]; [os] defaults to the current |
136 /// operating system. | 136 /// operating system. |
137 bool _eval(String expression, {TestPlatform platform, OperatingSystem os}) { | 137 bool _eval(String expression, {TestPlatform platform, OperatingSystem os}) { |
138 if (platform == null) platform = TestPlatform.vm; | 138 if (platform == null) platform = TestPlatform.vm; |
139 if (os == null) os = OperatingSystem.findByIoName(Platform.operatingSystem); | 139 if (os == null) os = OperatingSystem.findByIoName(Platform.operatingSystem); |
140 var selector = new PlatformSelector.parse(expression); | 140 var selector = new PlatformSelector.parse(expression); |
141 return selector.evaluate(platform, os: os); | 141 return selector.evaluate(platform, os: os); |
142 } | 142 } |
OLD | NEW |