| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 /// Tests that [Settings] instances can be serialized and deserialized. | 5 /// Tests that [Settings] instances can be serialized and deserialized. |
| 6 library fletch_tests.settings_persist; | 6 library dartino_tests.settings_persist; |
| 7 | 7 |
| 8 import 'dart:async' show Future; | 8 import 'dart:async' show Future; |
| 9 | 9 |
| 10 import 'dart:convert'; | 10 import 'dart:convert'; |
| 11 | 11 |
| 12 import 'package:fletchc/src/worker/developer.dart' show | 12 import 'package:dartino_compiler/src/worker/developer.dart' show |
| 13 Address, | 13 Address, |
| 14 DeviceType, | 14 DeviceType, |
| 15 IncrementalMode, | 15 IncrementalMode, |
| 16 Settings, | 16 Settings, |
| 17 parseSettings; | 17 parseSettings; |
| 18 | 18 |
| 19 import 'package:fletchc/src/verbs/infrastructure.dart' show | 19 import 'package:dartino_compiler/src/verbs/infrastructure.dart' show |
| 20 fileUri; | 20 fileUri; |
| 21 | 21 |
| 22 import 'package:expect/expect.dart'; | 22 import 'package:expect/expect.dart'; |
| 23 | 23 |
| 24 void testSettingsRoundTrip(Settings settings) { | 24 void testSettingsRoundTrip(Settings settings) { |
| 25 Settings before = settings; | 25 Settings before = settings; |
| 26 Map<String, dynamic> json = before.toJson(); | 26 Map<String, dynamic> json = before.toJson(); |
| 27 Settings after = parseSettings(const JsonCodec().encode(json), | 27 Settings after = parseSettings(const JsonCodec().encode(json), |
| 28 Uri.parse("file:///dummy.fletch-settings")); | 28 Uri.parse("file:///dummy.dartino-settings")); |
| 29 Expect.equals(before.packages, after.packages); | 29 Expect.equals(before.packages, after.packages); |
| 30 Expect.listEquals(before.options, after.options); | 30 Expect.listEquals(before.options, after.options); |
| 31 Expect.mapEquals(before.constants, after.constants); | 31 Expect.mapEquals(before.constants, after.constants); |
| 32 Expect.equals(before.deviceAddress, after.deviceAddress); | 32 Expect.equals(before.deviceAddress, after.deviceAddress); |
| 33 Expect.equals(before.deviceType, after.deviceType); | 33 Expect.equals(before.deviceType, after.deviceType); |
| 34 Expect.equals(before.incrementalMode, after.incrementalMode); | 34 Expect.equals(before.incrementalMode, after.incrementalMode); |
| 35 } | 35 } |
| 36 | 36 |
| 37 Future<Null> main() async { | 37 Future<Null> main() async { |
| 38 testSettingsRoundTrip(new Settings.empty()); | 38 testSettingsRoundTrip(new Settings.empty()); |
| 39 testSettingsRoundTrip(new Settings( | 39 testSettingsRoundTrip(new Settings( |
| 40 fileUri(".packages", Uri.base), | 40 fileUri(".packages", Uri.base), |
| 41 ["a", "b", "c"], | 41 ["a", "b", "c"], |
| 42 {"a": "A", "b": "b"}, | 42 {"a": "A", "b": "b"}, |
| 43 new Address("localhost", 8080), | 43 new Address("localhost", 8080), |
| 44 DeviceType.embedded, | 44 DeviceType.embedded, |
| 45 IncrementalMode.experimental)); | 45 IncrementalMode.experimental)); |
| 46 } | 46 } |
| OLD | NEW |