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

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

Issue 8276014: Update assert to follow the spec. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | « compiler/lib/implementation/core.js ('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) 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 // VMOptions=--enable_asserts 4 // VMOptions=--enable_type_checks
ahe 2011/10/14 10:45:40 I don't think this option belongs in language test
jat 2011/10/14 14:46:54 It is also understood by Dartc to do the same thin
5 // 5 //
6 // Dart test program testing assert statements. 6 // Dart test program testing assert statements.
7 7
8 class AssertTest { 8 class AssertionTest {
9 static test() { 9 static test() {
10 int i = 0; 10 int i = 0;
11 try { 11 try {
12 assert(false); 12 assert(false);
13 } catch (AssertError error) { 13 } catch (AssertionError error) {
14 i = 1; 14 i = 1;
15 Expect.equals("false", error.failedAssertion);
16 int pos = error.url.lastIndexOf("/", error.url.length);
17 if (pos == -1) {
18 pos = error.url.lastIndexOf("\\", error.url.length);
19 }
20 String subs = error.url.substring(pos + 1, error.url.length);
21 Expect.equals("AssertTest.dart", subs);
22 Expect.equals(12, error.line);
23 Expect.equals(14, error.column);
regis 2011/10/14 20:40:28 John, please do not remove valid testing of the vm
jat 2011/10/14 20:44:46 The test does not match the spec, so it seems reas
regis 2011/10/14 21:04:41 We are in agreement. I am not against renaming the
24 } 15 }
25 return i; 16 return i;
26 } 17 }
18
27 static testClosure() { 19 static testClosure() {
28 int i = 0; 20 int i = 0;
29 try { 21 try {
30 assert(() => false); 22 assert(() => false);
31 } catch (AssertError error) { 23 } catch (AssertionError error) {
32 i = 1; 24 i = 1;
33 Expect.equals("() => false", error.failedAssertion);
34 int pos = error.url.lastIndexOf("/", error.url.length);
35 if (pos == -1) {
36 pos = error.url.lastIndexOf("\\", error.url.length);
37 }
38 String subs = error.url.substring(pos + 1, error.url.length);
39 Expect.equals("AssertTest.dart", subs);
40 Expect.equals(30, error.line);
41 Expect.equals(14, error.column);
42 } 25 }
43 return i; 26 return i;
44 } 27 }
45 28
29 static testClosure2() {
ahe 2011/10/14 10:45:40 This method isn't called.
30 int i = 0;
31 try {
32 var x = () => false;
33 assert(x);
34 } catch (AssertionError error) {
35 i = 1;
36 }
37 return i;
38 }
39
40
46 static testMain() { 41 static testMain() {
47 Expect.equals(1, test()); 42 Expect.equals(1, test());
48 Expect.equals(1, testClosure()); 43 Expect.equals(1, testClosure());
ahe 2011/10/14 10:45:40 Could you add a few more test cases, for example:
49 } 44 }
50 } 45 }
51 46
52 main() { 47 main() {
53 AssertTest.testMain(); 48 AssertionTest.testMain();
54 } 49 }
OLDNEW
« no previous file with comments | « compiler/lib/implementation/core.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698