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

Side by Side Diff: dart/tests/language/src/InterfaceFactoryTest.dart

Issue 8958011: One more factory -> default pass. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test that the two major variations of interface factories work. 5 // Test that the two major variations of interface factories work.
6 6
7 // Variant 1. The factory class implements the interface and provides 7 // Variant 1. The factory class implements the interface and provides
8 // a default implementation of the interface. 8 // a default implementation of the interface.
9 9
10 interface Interface1 factory DefaultImplementation { 10 interface Interface1 default DefaultImplementation {
11 Interface1(var secret); 11 Interface1(var secret);
12 Interface1.named(); 12 Interface1.named();
13 13
14 GetSecret(); 14 GetSecret();
15 } 15 }
16 16
17 class DefaultImplementation implements Interface1 { 17 class DefaultImplementation implements Interface1 {
18 int _secret; 18 int _secret;
19 19
20 DefaultImplementation(int this._secret) {} 20 DefaultImplementation(int this._secret) {}
21 DefaultImplementation.named() : this._secret = 11 {} 21 DefaultImplementation.named() : this._secret = 11 {}
22 22
23 int GetSecret() { return _secret; } 23 int GetSecret() { return _secret; }
24 24
25 static testMain() { 25 static testMain() {
26 Expect.equals(7, new Interface1(7).GetSecret()); 26 Expect.equals(7, new Interface1(7).GetSecret());
27 Expect.equals(11, new Interface1.named().GetSecret()); 27 Expect.equals(11, new Interface1.named().GetSecret());
28 } 28 }
29 } 29 }
30 30
31 // Variant 2. The factory class provides factory constructors for the 31 // Variant 2. The factory class provides factory constructors for the
32 // interface. 32 // interface.
33 33
34 interface Interface2 factory FactoryProvider { 34 interface Interface2 default FactoryProvider {
35 Interface2(var secret); 35 Interface2(var secret);
36 Interface2.named(); 36 Interface2.named();
37 37
38 GetSecret(); 38 GetSecret();
39 } 39 }
40 40
41 class SomeImplementation implements Interface2 { 41 class SomeImplementation implements Interface2 {
42 String _secret; 42 String _secret;
43 43
44 SomeImplementation(String one, String two) : _secret = one + two {} 44 SomeImplementation(String one, String two) : _secret = one + two {}
(...skipping 14 matching lines...) Expand all
59 static testMain() { 59 static testMain() {
60 Expect.equals("cobracobra", new Interface2("cobra").GetSecret()); 60 Expect.equals("cobracobra", new Interface2("cobra").GetSecret());
61 Expect.equals("NamedConstructor", new Interface2.named().GetSecret()); 61 Expect.equals("NamedConstructor", new Interface2.named().GetSecret());
62 } 62 }
63 } 63 }
64 64
65 main() { 65 main() {
66 DefaultImplementation.testMain(); 66 DefaultImplementation.testMain();
67 FactoryProvider.testMain(); 67 FactoryProvider.testMain();
68 } 68 }
OLDNEW
« no previous file with comments | « dart/tests/language/src/InterfaceFactoryMultiTest.dart ('k') | dart/tests/language/src/InterfaceTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698