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

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

Issue 9969159: - Remove more String operator + from tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
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 // String concatenation test. 4 // String concatenation test.
5 5
6 interface V { 6 interface V {
7 static final Version = "7.3.5.3"; 7 static final Version = "7.3.5.3";
8 } 8 }
9 9
10 10
11 class StringConcatTest { 11 class StringConcatTest {
12 12
13 static final Tag = "version-" + V.Version; 13 static final Tag = "version-" + V.Version;
hausner 2012/04/11 18:01:24 There are many more cases of string + in this test
Ivan Posva 2012/04/13 13:29:17 I only addressed dynamically executed + operations
14 14
15 static Answer() { 15 static Answer() {
16 return 42; 16 return 42;
17 } 17 }
18 18
19 static testMain() { 19 static testMain() {
20 int nofExceptions = 0; 20 int nofExceptions = 0;
21 21
22 var x = 3; 22 var x = 3;
23 var y = 5; 23 var y = 5;
24 Expect.equals("" + x + y, "35"); 24 Expect.equals("" + x + y, "35");
25 Expect.equals(x + y, 8); 25 Expect.equals(x + y, 8);
26 26
27 var s1 = "The answer is " + Answer() + '.'; 27 var s1 = "The answer is " + Answer() + '.';
28 Expect.equals(s1, "The answer is 42."); 28 Expect.equals(s1, "The answer is 42.");
29 29
30 Expect.equals("version-7.3.5.3", Tag); 30 Expect.equals("version-7.3.5.3", Tag);
31 31
32 // Adding a number to a string value creates a new, concatenated 32 // Adding a number to a string value creates a new, concatenated
33 // string. 33 // string.
34 s1 = "Grandmaster Flash and the Furious "; 34 s1 = "Grandmaster Flash and the Furious ";
35 s1 = s1 + (4 + 1); 35 s1 = "$s1${4 + 1}";
36 Expect.equals(true, s1.endsWith("Furious 5")); 36 Expect.equals(true, s1.endsWith("Furious 5"));
37 37
38 // Adding a string to a number is not supported. 38 // Adding a string to a number is not supported.
39 try { 39 try {
40 String cantDo = x + " should't work"; // throws noSuchMethodException. 40 String cantDo = x + " should't work"; // throws noSuchMethodException.
41 Expect.equals(1, 0); // this should never be executed. 41 Expect.equals(1, 0); // this should never be executed.
42 } catch(NoSuchMethodException e) { 42 } catch(NoSuchMethodException e) {
43 // In default mode. 43 // In default mode.
44 nofExceptions++; 44 nofExceptions++;
45 } catch (TypeError e) { 45 } catch (TypeError e) {
(...skipping 15 matching lines...) Expand all
61 Expect.equals(true, fake === "Milli Vanilli"); 61 Expect.equals(true, fake === "Milli Vanilli");
62 Expect.equals(true, fake === "Milli " + 'Vanilli'); 62 Expect.equals(true, fake === "Milli " + 'Vanilli');
63 63
64 Expect.equals(nofExceptions, 1); 64 Expect.equals(nofExceptions, 1);
65 } 65 }
66 } 66 }
67 67
68 main() { 68 main() {
69 StringConcatTest.testMain(); 69 StringConcatTest.testMain();
70 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698