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

Side by Side Diff: tests/lib/convert/codec1_test.dart

Issue 22979003: add a const ctor to Converter (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated tests Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/convert/converter.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 'dart:convert'; 5 import 'dart:convert';
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 8
9 class MyCodec extends Codec<int, String> { 9 class MyCodec extends Codec<int, String> {
10 const MyCodec(); 10 const MyCodec();
11 11
12 Converter<int, String> get encoder => new IntStringConverter(); 12 final Converter<int, String> encoder = const IntStringConverter();
13 Converter<String, int> get decoder => new StringIntConverter(); 13 final Converter<String, int> decoder = const StringIntConverter();
14 } 14 }
15 15
16 class IntStringConverter extends Converter<int, String> { 16 class IntStringConverter extends Converter<int, String> {
17 const IntStringConverter();
18
17 String convert(int i) => i.toString(); 19 String convert(int i) => i.toString();
18 } 20 }
19 21
20 class StringIntConverter extends Converter<String, int> { 22 class StringIntConverter extends Converter<String, int> {
23 const StringIntConverter();
24
21 int convert(String str) => int.parse(str); 25 int convert(String str) => int.parse(str);
22 } 26 }
23 27
24 class MyCodec2 extends Codec<int, String> { 28 class MyCodec2 extends Codec<int, String> {
25 const MyCodec2(); 29 const MyCodec2();
26 30
27 Converter<int, String> get encoder => new IntStringConverter2(); 31 Converter<int, String> get encoder => new IntStringConverter2();
28 Converter<String, int> get decoder => new StringIntConverter2(); 32 Converter<String, int> get decoder => new StringIntConverter2();
29 } 33 }
30 34
(...skipping 29 matching lines...) Expand all
60 64
61 inverted = TEST_CODEC2.inverted; 65 inverted = TEST_CODEC2.inverted;
62 fused = TEST_CODEC2.fuse(inverted); 66 fused = TEST_CODEC2.fuse(inverted);
63 Expect.equals(499, fused.encode(0)); 67 Expect.equals(499, fused.encode(0));
64 Expect.equals(499, fused.decode(0)); 68 Expect.equals(499, fused.decode(0));
65 69
66 fused = TEST_CODEC.fuse(inverted); 70 fused = TEST_CODEC.fuse(inverted);
67 Expect.equals(405, fused.encode(5)); 71 Expect.equals(405, fused.encode(5));
68 Expect.equals(101, fused.decode(2)); 72 Expect.equals(101, fused.decode(2));
69 } 73 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/converter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698