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

Side by Side Diff: tests/corelib/format_exception_test.dart

Issue 3004073002: Remove corelib/corelib_strong and migrate last two remaining tests. (Closed)
Patch Set: Created 3 years, 3 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library format_exception_test;
6
7 import "package:expect/expect.dart";
8
9 test(exn, message, source, offset, toString) {
10 Expect.equals(message, exn.message);
11 Expect.equals(source, exn.source);
12 Expect.equals(offset, exn.offset);
13 Expect.equals(toString, exn.toString());
14 }
15
16 main() {
17 var e;
18 e = new FormatException();
19 test(e, "", null, null, "FormatException");
20 e = new FormatException("");
21 test(e, "", null, null, "FormatException");
22 e = new FormatException(null);
23 test(e, null, null, null, "FormatException");
24
25 e = new FormatException("message");
26 test(e, "message", null, null, "FormatException: message");
27
28 e = new FormatException("message", "source");
29 test(e, "message", "source", null, "FormatException: message\nsource");
30
31 e = new FormatException("message", "source" * 25);
32 test(e, "message", "source" * 25, null,
33 "FormatException: message\n" + "source" * 12 + "sou...");
34 e = new FormatException("message", "source" * 25);
35 test(e, "message", "source" * 25, null,
36 "FormatException: message\n" + "source" * 12 + "sou...");
37 e = new FormatException("message", "s1\nsource\ns2");
38 test(e, "message", "s1\nsource\ns2", null,
39 "FormatException: message\n" + "s1\nsource\ns2");
40
41 var o = new Object();
42 e = new FormatException("message", o, 10);
43 test(e, "message", o, 10, "FormatException: message (at offset 10)");
44
45 e = new FormatException("message", "source", 3);
46 test(e, "message", "source", 3,
47 "FormatException: message (at character 4)\nsource\n ^\n");
48
49 e = new FormatException("message", "s1\nsource\ns2", 6);
50 test(e, "message", "s1\nsource\ns2", 6,
51 "FormatException: message (at line 2, character 4)\nsource\n ^\n");
52
53 var longline = "watermelon cantaloupe " * 8 + "watermelon"; // Length > 160.
54 var longsource = (longline + "\n") * 25;
55 var line10 = (longline.length + 1) * 9;
56 e = new FormatException("message", longsource, line10);
57 test(
58 e,
59 "message",
60 longsource,
61 line10,
62 "FormatException: message (at line 10, character 1)\n"
63 "${longline.substring(0, 75)}...\n^\n");
64
65 e = new FormatException("message", longsource, line10 - 1);
66 test(
67 e,
68 "message",
69 longsource,
70 line10 - 1,
71 "FormatException: message (at line 9, "
72 "character ${longline.length + 1})\n"
73 "...${longline.substring(longline.length - 75)}\n"
74 "${' ' * 78}^\n");
75
76 var half = longline.length ~/ 2;
77 e = new FormatException("message", longsource, line10 + half);
78 test(
79 e,
80 "message",
81 longsource,
82 line10 + half,
83 "FormatException: message (at line 10, character ${half + 1})\n"
84 "...${longline.substring(half - 36, half + 36)}...\n"
85 "${' ' * 39}^\n");
86
87 var sourceNL = "\nsource with leading NL";
88 e = new FormatException("message", sourceNL, 2);
89 test(
90 e,
91 "message",
92 sourceNL,
93 2,
94 "FormatException: message (at line 2, character 2)\n"
95 "source with leading NL\n"
96 " ^\n");
97
98 var sourceNL2 = "\n\nsource with leading NL";
99 e = new FormatException("message", sourceNL2, 2);
100 test(
101 e,
102 "message",
103 sourceNL2,
104 2,
105 "FormatException: message (at line 3, character 1)\n"
106 "source with leading NL\n"
107 "^\n");
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698