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

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 1647183002: Move more constant tests to constant_test.dart file. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/constant_test.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library analyzer.test.generated.all_the_rest_test; 5 library analyzer.test.generated.all_the_rest_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/file_system/physical_file_system.dart'; 10 import 'package:analyzer/file_system/physical_file_system.dart';
11 import 'package:analyzer/src/dart/ast/utilities.dart' hide ConstantEvaluator; 11 import 'package:analyzer/src/dart/ast/utilities.dart' hide ConstantEvaluator;
12 import 'package:analyzer/src/dart/element/element.dart'; 12 import 'package:analyzer/src/dart/element/element.dart';
13 import 'package:analyzer/src/generated/constant.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/error.dart'; 14 import 'package:analyzer/src/generated/error.dart';
16 import 'package:analyzer/src/generated/java_core.dart'; 15 import 'package:analyzer/src/generated/java_core.dart';
17 import 'package:analyzer/src/generated/java_engine_io.dart'; 16 import 'package:analyzer/src/generated/java_engine_io.dart';
18 import 'package:analyzer/src/generated/java_io.dart'; 17 import 'package:analyzer/src/generated/java_io.dart';
19 import 'package:analyzer/src/generated/resolver.dart'; 18 import 'package:analyzer/src/generated/resolver.dart';
20 import 'package:analyzer/src/generated/scanner.dart'; 19 import 'package:analyzer/src/generated/scanner.dart';
21 import 'package:analyzer/src/generated/sdk.dart'; 20 import 'package:analyzer/src/generated/sdk.dart';
22 import 'package:analyzer/src/generated/sdk_io.dart'; 21 import 'package:analyzer/src/generated/sdk_io.dart';
23 import 'package:analyzer/src/generated/source.dart'; 22 import 'package:analyzer/src/generated/source.dart';
(...skipping 10 matching lines...) Expand all
34 import '../reflective_tests.dart'; 33 import '../reflective_tests.dart';
35 import '../utils.dart'; 34 import '../utils.dart';
36 import 'parser_test.dart'; 35 import 'parser_test.dart';
37 import 'resolver_test.dart'; 36 import 'resolver_test.dart';
38 import 'test_support.dart'; 37 import 'test_support.dart';
39 38
40 main() { 39 main() {
41 initializeTestEnvironment(); 40 initializeTestEnvironment();
42 runReflectiveTests(ContentCacheTest); 41 runReflectiveTests(ContentCacheTest);
43 runReflectiveTests(CustomUriResolverTest); 42 runReflectiveTests(CustomUriResolverTest);
44 runReflectiveTests(DartObjectImplTest);
45 runReflectiveTests(DartUriResolverTest); 43 runReflectiveTests(DartUriResolverTest);
46 runReflectiveTests(DeclaredVariablesTest);
47 runReflectiveTests(DirectoryBasedDartSdkTest); 44 runReflectiveTests(DirectoryBasedDartSdkTest);
48 runReflectiveTests(DirectoryBasedSourceContainerTest); 45 runReflectiveTests(DirectoryBasedSourceContainerTest);
49 runReflectiveTests(ElementBuilderTest); 46 runReflectiveTests(ElementBuilderTest);
50 runReflectiveTests(ElementLocatorTest); 47 runReflectiveTests(ElementLocatorTest);
51 runReflectiveTests(EnumMemberBuilderTest); 48 runReflectiveTests(EnumMemberBuilderTest);
52 runReflectiveTests(ErrorReporterTest); 49 runReflectiveTests(ErrorReporterTest);
53 runReflectiveTests(ErrorSeverityTest); 50 runReflectiveTests(ErrorSeverityTest);
54 runReflectiveTests(ExitDetectorTest); 51 runReflectiveTests(ExitDetectorTest);
55 runReflectiveTests(ExitDetectorTest2); 52 runReflectiveTests(ExitDetectorTest2);
56 runReflectiveTests(FileBasedSourceTest); 53 runReflectiveTests(FileBasedSourceTest);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath(); 94 FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath();
98 UriResolver resolver = new CustomUriResolver({'custom:library': path,}); 95 UriResolver resolver = new CustomUriResolver({'custom:library': path,});
99 Source result = 96 Source result =
100 resolver.resolveAbsolute(parseUriWithException("custom:library")); 97 resolver.resolveAbsolute(parseUriWithException("custom:library"));
101 expect(result, isNotNull); 98 expect(result, isNotNull);
102 expect(result.fullName, path); 99 expect(result.fullName, path);
103 } 100 }
104 } 101 }
105 102
106 @reflectiveTest 103 @reflectiveTest
107 class DartObjectImplTest extends EngineTestCase {
108 TypeProvider _typeProvider = new TestTypeProvider();
109
110 void test_add_knownDouble_knownDouble() {
111 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _doubleValue(2.0));
112 }
113
114 void test_add_knownDouble_knownInt() {
115 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _intValue(2));
116 }
117
118 void test_add_knownDouble_unknownDouble() {
119 _assertAdd(_doubleValue(null), _doubleValue(1.0), _doubleValue(null));
120 }
121
122 void test_add_knownDouble_unknownInt() {
123 _assertAdd(_doubleValue(null), _doubleValue(1.0), _intValue(null));
124 }
125
126 void test_add_knownInt_knownInt() {
127 _assertAdd(_intValue(3), _intValue(1), _intValue(2));
128 }
129
130 void test_add_knownInt_knownString() {
131 _assertAdd(null, _intValue(1), _stringValue("2"));
132 }
133
134 void test_add_knownInt_unknownDouble() {
135 _assertAdd(_doubleValue(null), _intValue(1), _doubleValue(null));
136 }
137
138 void test_add_knownInt_unknownInt() {
139 _assertAdd(_intValue(null), _intValue(1), _intValue(null));
140 }
141
142 void test_add_knownString_knownInt() {
143 _assertAdd(null, _stringValue("1"), _intValue(2));
144 }
145
146 void test_add_knownString_knownString() {
147 _assertAdd(_stringValue("ab"), _stringValue("a"), _stringValue("b"));
148 }
149
150 void test_add_knownString_unknownString() {
151 _assertAdd(_stringValue(null), _stringValue("a"), _stringValue(null));
152 }
153
154 void test_add_unknownDouble_knownDouble() {
155 _assertAdd(_doubleValue(null), _doubleValue(null), _doubleValue(2.0));
156 }
157
158 void test_add_unknownDouble_knownInt() {
159 _assertAdd(_doubleValue(null), _doubleValue(null), _intValue(2));
160 }
161
162 void test_add_unknownInt_knownDouble() {
163 _assertAdd(_doubleValue(null), _intValue(null), _doubleValue(2.0));
164 }
165
166 void test_add_unknownInt_knownInt() {
167 _assertAdd(_intValue(null), _intValue(null), _intValue(2));
168 }
169
170 void test_add_unknownString_knownString() {
171 _assertAdd(_stringValue(null), _stringValue(null), _stringValue("b"));
172 }
173
174 void test_add_unknownString_unknownString() {
175 _assertAdd(_stringValue(null), _stringValue(null), _stringValue(null));
176 }
177
178 void test_bitAnd_knownInt_knownInt() {
179 _assertBitAnd(_intValue(2), _intValue(6), _intValue(3));
180 }
181
182 void test_bitAnd_knownInt_knownString() {
183 _assertBitAnd(null, _intValue(6), _stringValue("3"));
184 }
185
186 void test_bitAnd_knownInt_unknownInt() {
187 _assertBitAnd(_intValue(null), _intValue(6), _intValue(null));
188 }
189
190 void test_bitAnd_knownString_knownInt() {
191 _assertBitAnd(null, _stringValue("6"), _intValue(3));
192 }
193
194 void test_bitAnd_unknownInt_knownInt() {
195 _assertBitAnd(_intValue(null), _intValue(null), _intValue(3));
196 }
197
198 void test_bitAnd_unknownInt_unknownInt() {
199 _assertBitAnd(_intValue(null), _intValue(null), _intValue(null));
200 }
201
202 void test_bitNot_knownInt() {
203 _assertBitNot(_intValue(-4), _intValue(3));
204 }
205
206 void test_bitNot_knownString() {
207 _assertBitNot(null, _stringValue("6"));
208 }
209
210 void test_bitNot_unknownInt() {
211 _assertBitNot(_intValue(null), _intValue(null));
212 }
213
214 void test_bitOr_knownInt_knownInt() {
215 _assertBitOr(_intValue(7), _intValue(6), _intValue(3));
216 }
217
218 void test_bitOr_knownInt_knownString() {
219 _assertBitOr(null, _intValue(6), _stringValue("3"));
220 }
221
222 void test_bitOr_knownInt_unknownInt() {
223 _assertBitOr(_intValue(null), _intValue(6), _intValue(null));
224 }
225
226 void test_bitOr_knownString_knownInt() {
227 _assertBitOr(null, _stringValue("6"), _intValue(3));
228 }
229
230 void test_bitOr_unknownInt_knownInt() {
231 _assertBitOr(_intValue(null), _intValue(null), _intValue(3));
232 }
233
234 void test_bitOr_unknownInt_unknownInt() {
235 _assertBitOr(_intValue(null), _intValue(null), _intValue(null));
236 }
237
238 void test_bitXor_knownInt_knownInt() {
239 _assertBitXor(_intValue(5), _intValue(6), _intValue(3));
240 }
241
242 void test_bitXor_knownInt_knownString() {
243 _assertBitXor(null, _intValue(6), _stringValue("3"));
244 }
245
246 void test_bitXor_knownInt_unknownInt() {
247 _assertBitXor(_intValue(null), _intValue(6), _intValue(null));
248 }
249
250 void test_bitXor_knownString_knownInt() {
251 _assertBitXor(null, _stringValue("6"), _intValue(3));
252 }
253
254 void test_bitXor_unknownInt_knownInt() {
255 _assertBitXor(_intValue(null), _intValue(null), _intValue(3));
256 }
257
258 void test_bitXor_unknownInt_unknownInt() {
259 _assertBitXor(_intValue(null), _intValue(null), _intValue(null));
260 }
261
262 void test_concatenate_knownInt_knownString() {
263 _assertConcatenate(null, _intValue(2), _stringValue("def"));
264 }
265
266 void test_concatenate_knownString_knownInt() {
267 _assertConcatenate(null, _stringValue("abc"), _intValue(3));
268 }
269
270 void test_concatenate_knownString_knownString() {
271 _assertConcatenate(
272 _stringValue("abcdef"), _stringValue("abc"), _stringValue("def"));
273 }
274
275 void test_concatenate_knownString_unknownString() {
276 _assertConcatenate(
277 _stringValue(null), _stringValue("abc"), _stringValue(null));
278 }
279
280 void test_concatenate_unknownString_knownString() {
281 _assertConcatenate(
282 _stringValue(null), _stringValue(null), _stringValue("def"));
283 }
284
285 void test_divide_knownDouble_knownDouble() {
286 _assertDivide(_doubleValue(3.0), _doubleValue(6.0), _doubleValue(2.0));
287 }
288
289 void test_divide_knownDouble_knownInt() {
290 _assertDivide(_doubleValue(3.0), _doubleValue(6.0), _intValue(2));
291 }
292
293 void test_divide_knownDouble_unknownDouble() {
294 _assertDivide(_doubleValue(null), _doubleValue(6.0), _doubleValue(null));
295 }
296
297 void test_divide_knownDouble_unknownInt() {
298 _assertDivide(_doubleValue(null), _doubleValue(6.0), _intValue(null));
299 }
300
301 void test_divide_knownInt_knownInt() {
302 _assertDivide(_doubleValue(3.0), _intValue(6), _intValue(2));
303 }
304
305 void test_divide_knownInt_knownString() {
306 _assertDivide(null, _intValue(6), _stringValue("2"));
307 }
308
309 void test_divide_knownInt_unknownDouble() {
310 _assertDivide(_doubleValue(null), _intValue(6), _doubleValue(null));
311 }
312
313 void test_divide_knownInt_unknownInt() {
314 _assertDivide(_doubleValue(null), _intValue(6), _intValue(null));
315 }
316
317 void test_divide_knownString_knownInt() {
318 _assertDivide(null, _stringValue("6"), _intValue(2));
319 }
320
321 void test_divide_unknownDouble_knownDouble() {
322 _assertDivide(_doubleValue(null), _doubleValue(null), _doubleValue(2.0));
323 }
324
325 void test_divide_unknownDouble_knownInt() {
326 _assertDivide(_doubleValue(null), _doubleValue(null), _intValue(2));
327 }
328
329 void test_divide_unknownInt_knownDouble() {
330 _assertDivide(_doubleValue(null), _intValue(null), _doubleValue(2.0));
331 }
332
333 void test_divide_unknownInt_knownInt() {
334 _assertDivide(_doubleValue(null), _intValue(null), _intValue(2));
335 }
336
337 void test_equalEqual_bool_false() {
338 _assertEqualEqual(_boolValue(false), _boolValue(false), _boolValue(true));
339 }
340
341 void test_equalEqual_bool_true() {
342 _assertEqualEqual(_boolValue(true), _boolValue(true), _boolValue(true));
343 }
344
345 void test_equalEqual_bool_unknown() {
346 _assertEqualEqual(_boolValue(null), _boolValue(null), _boolValue(false));
347 }
348
349 void test_equalEqual_double_false() {
350 _assertEqualEqual(_boolValue(false), _doubleValue(2.0), _doubleValue(4.0));
351 }
352
353 void test_equalEqual_double_true() {
354 _assertEqualEqual(_boolValue(true), _doubleValue(2.0), _doubleValue(2.0));
355 }
356
357 void test_equalEqual_double_unknown() {
358 _assertEqualEqual(_boolValue(null), _doubleValue(1.0), _doubleValue(null));
359 }
360
361 void test_equalEqual_int_false() {
362 _assertEqualEqual(_boolValue(false), _intValue(-5), _intValue(5));
363 }
364
365 void test_equalEqual_int_true() {
366 _assertEqualEqual(_boolValue(true), _intValue(5), _intValue(5));
367 }
368
369 void test_equalEqual_int_unknown() {
370 _assertEqualEqual(_boolValue(null), _intValue(null), _intValue(3));
371 }
372
373 void test_equalEqual_list_empty() {
374 _assertEqualEqual(null, _listValue(), _listValue());
375 }
376
377 void test_equalEqual_list_false() {
378 _assertEqualEqual(null, _listValue(), _listValue());
379 }
380
381 void test_equalEqual_map_empty() {
382 _assertEqualEqual(null, _mapValue(), _mapValue());
383 }
384
385 void test_equalEqual_map_false() {
386 _assertEqualEqual(null, _mapValue(), _mapValue());
387 }
388
389 void test_equalEqual_null() {
390 _assertEqualEqual(_boolValue(true), _nullValue(), _nullValue());
391 }
392
393 void test_equalEqual_string_false() {
394 _assertEqualEqual(
395 _boolValue(false), _stringValue("abc"), _stringValue("def"));
396 }
397
398 void test_equalEqual_string_true() {
399 _assertEqualEqual(
400 _boolValue(true), _stringValue("abc"), _stringValue("abc"));
401 }
402
403 void test_equalEqual_string_unknown() {
404 _assertEqualEqual(
405 _boolValue(null), _stringValue(null), _stringValue("def"));
406 }
407
408 void test_equals_list_false_differentSizes() {
409 expect(
410 _listValue([_boolValue(true)]) ==
411 _listValue([_boolValue(true), _boolValue(false)]),
412 isFalse);
413 }
414
415 void test_equals_list_false_sameSize() {
416 expect(_listValue([_boolValue(true)]) == _listValue([_boolValue(false)]),
417 isFalse);
418 }
419
420 void test_equals_list_true_empty() {
421 expect(_listValue(), _listValue());
422 }
423
424 void test_equals_list_true_nonEmpty() {
425 expect(_listValue([_boolValue(true)]), _listValue([_boolValue(true)]));
426 }
427
428 void test_equals_map_true_empty() {
429 expect(_mapValue(), _mapValue());
430 }
431
432 void test_equals_symbol_false() {
433 expect(_symbolValue("a") == _symbolValue("b"), isFalse);
434 }
435
436 void test_equals_symbol_true() {
437 expect(_symbolValue("a"), _symbolValue("a"));
438 }
439
440 void test_getValue_bool_false() {
441 expect(_boolValue(false).toBoolValue(), false);
442 }
443
444 void test_getValue_bool_true() {
445 expect(_boolValue(true).toBoolValue(), true);
446 }
447
448 void test_getValue_bool_unknown() {
449 expect(_boolValue(null).toBoolValue(), isNull);
450 }
451
452 void test_getValue_double_known() {
453 double value = 2.3;
454 expect(_doubleValue(value).toDoubleValue(), value);
455 }
456
457 void test_getValue_double_unknown() {
458 expect(_doubleValue(null).toDoubleValue(), isNull);
459 }
460
461 void test_getValue_int_known() {
462 int value = 23;
463 expect(_intValue(value).toIntValue(), value);
464 }
465
466 void test_getValue_int_unknown() {
467 expect(_intValue(null).toIntValue(), isNull);
468 }
469
470 void test_getValue_list_empty() {
471 Object result = _listValue().toListValue();
472 _assertInstanceOfObjectArray(result);
473 List<Object> array = result as List<Object>;
474 expect(array, hasLength(0));
475 }
476
477 void test_getValue_list_valid() {
478 Object result = _listValue([_intValue(23)]).toListValue();
479 _assertInstanceOfObjectArray(result);
480 List<Object> array = result as List<Object>;
481 expect(array, hasLength(1));
482 }
483
484 void test_getValue_map_empty() {
485 Object result = _mapValue().toMapValue();
486 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result);
487 Map map = result as Map;
488 expect(map, hasLength(0));
489 }
490
491 void test_getValue_map_valid() {
492 Object result =
493 _mapValue([_stringValue("key"), _stringValue("value")]).toMapValue();
494 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result);
495 Map map = result as Map;
496 expect(map, hasLength(1));
497 }
498
499 void test_getValue_null() {
500 expect(_nullValue().isNull, isTrue);
501 }
502
503 void test_getValue_string_known() {
504 String value = "twenty-three";
505 expect(_stringValue(value).toStringValue(), value);
506 }
507
508 void test_getValue_string_unknown() {
509 expect(_stringValue(null).toStringValue(), isNull);
510 }
511
512 void test_greaterThan_knownDouble_knownDouble_false() {
513 _assertGreaterThan(_boolValue(false), _doubleValue(1.0), _doubleValue(2.0));
514 }
515
516 void test_greaterThan_knownDouble_knownDouble_true() {
517 _assertGreaterThan(_boolValue(true), _doubleValue(2.0), _doubleValue(1.0));
518 }
519
520 void test_greaterThan_knownDouble_knownInt_false() {
521 _assertGreaterThan(_boolValue(false), _doubleValue(1.0), _intValue(2));
522 }
523
524 void test_greaterThan_knownDouble_knownInt_true() {
525 _assertGreaterThan(_boolValue(true), _doubleValue(2.0), _intValue(1));
526 }
527
528 void test_greaterThan_knownDouble_unknownDouble() {
529 _assertGreaterThan(_boolValue(null), _doubleValue(1.0), _doubleValue(null));
530 }
531
532 void test_greaterThan_knownDouble_unknownInt() {
533 _assertGreaterThan(_boolValue(null), _doubleValue(1.0), _intValue(null));
534 }
535
536 void test_greaterThan_knownInt_knownInt_false() {
537 _assertGreaterThan(_boolValue(false), _intValue(1), _intValue(2));
538 }
539
540 void test_greaterThan_knownInt_knownInt_true() {
541 _assertGreaterThan(_boolValue(true), _intValue(2), _intValue(1));
542 }
543
544 void test_greaterThan_knownInt_knownString() {
545 _assertGreaterThan(null, _intValue(1), _stringValue("2"));
546 }
547
548 void test_greaterThan_knownInt_unknownDouble() {
549 _assertGreaterThan(_boolValue(null), _intValue(1), _doubleValue(null));
550 }
551
552 void test_greaterThan_knownInt_unknownInt() {
553 _assertGreaterThan(_boolValue(null), _intValue(1), _intValue(null));
554 }
555
556 void test_greaterThan_knownString_knownInt() {
557 _assertGreaterThan(null, _stringValue("1"), _intValue(2));
558 }
559
560 void test_greaterThan_unknownDouble_knownDouble() {
561 _assertGreaterThan(_boolValue(null), _doubleValue(null), _doubleValue(2.0));
562 }
563
564 void test_greaterThan_unknownDouble_knownInt() {
565 _assertGreaterThan(_boolValue(null), _doubleValue(null), _intValue(2));
566 }
567
568 void test_greaterThan_unknownInt_knownDouble() {
569 _assertGreaterThan(_boolValue(null), _intValue(null), _doubleValue(2.0));
570 }
571
572 void test_greaterThan_unknownInt_knownInt() {
573 _assertGreaterThan(_boolValue(null), _intValue(null), _intValue(2));
574 }
575
576 void test_greaterThanOrEqual_knownDouble_knownDouble_false() {
577 _assertGreaterThanOrEqual(
578 _boolValue(false), _doubleValue(1.0), _doubleValue(2.0));
579 }
580
581 void test_greaterThanOrEqual_knownDouble_knownDouble_true() {
582 _assertGreaterThanOrEqual(
583 _boolValue(true), _doubleValue(2.0), _doubleValue(1.0));
584 }
585
586 void test_greaterThanOrEqual_knownDouble_knownInt_false() {
587 _assertGreaterThanOrEqual(
588 _boolValue(false), _doubleValue(1.0), _intValue(2));
589 }
590
591 void test_greaterThanOrEqual_knownDouble_knownInt_true() {
592 _assertGreaterThanOrEqual(
593 _boolValue(true), _doubleValue(2.0), _intValue(1));
594 }
595
596 void test_greaterThanOrEqual_knownDouble_unknownDouble() {
597 _assertGreaterThanOrEqual(
598 _boolValue(null), _doubleValue(1.0), _doubleValue(null));
599 }
600
601 void test_greaterThanOrEqual_knownDouble_unknownInt() {
602 _assertGreaterThanOrEqual(
603 _boolValue(null), _doubleValue(1.0), _intValue(null));
604 }
605
606 void test_greaterThanOrEqual_knownInt_knownInt_false() {
607 _assertGreaterThanOrEqual(_boolValue(false), _intValue(1), _intValue(2));
608 }
609
610 void test_greaterThanOrEqual_knownInt_knownInt_true() {
611 _assertGreaterThanOrEqual(_boolValue(true), _intValue(2), _intValue(2));
612 }
613
614 void test_greaterThanOrEqual_knownInt_knownString() {
615 _assertGreaterThanOrEqual(null, _intValue(1), _stringValue("2"));
616 }
617
618 void test_greaterThanOrEqual_knownInt_unknownDouble() {
619 _assertGreaterThanOrEqual(
620 _boolValue(null), _intValue(1), _doubleValue(null));
621 }
622
623 void test_greaterThanOrEqual_knownInt_unknownInt() {
624 _assertGreaterThanOrEqual(_boolValue(null), _intValue(1), _intValue(null));
625 }
626
627 void test_greaterThanOrEqual_knownString_knownInt() {
628 _assertGreaterThanOrEqual(null, _stringValue("1"), _intValue(2));
629 }
630
631 void test_greaterThanOrEqual_unknownDouble_knownDouble() {
632 _assertGreaterThanOrEqual(
633 _boolValue(null), _doubleValue(null), _doubleValue(2.0));
634 }
635
636 void test_greaterThanOrEqual_unknownDouble_knownInt() {
637 _assertGreaterThanOrEqual(
638 _boolValue(null), _doubleValue(null), _intValue(2));
639 }
640
641 void test_greaterThanOrEqual_unknownInt_knownDouble() {
642 _assertGreaterThanOrEqual(
643 _boolValue(null), _intValue(null), _doubleValue(2.0));
644 }
645
646 void test_greaterThanOrEqual_unknownInt_knownInt() {
647 _assertGreaterThanOrEqual(_boolValue(null), _intValue(null), _intValue(2));
648 }
649
650 void test_hasKnownValue_bool_false() {
651 expect(_boolValue(false).hasKnownValue, isTrue);
652 }
653
654 void test_hasKnownValue_bool_true() {
655 expect(_boolValue(true).hasKnownValue, isTrue);
656 }
657
658 void test_hasKnownValue_bool_unknown() {
659 expect(_boolValue(null).hasKnownValue, isFalse);
660 }
661
662 void test_hasKnownValue_double_known() {
663 expect(_doubleValue(2.3).hasKnownValue, isTrue);
664 }
665
666 void test_hasKnownValue_double_unknown() {
667 expect(_doubleValue(null).hasKnownValue, isFalse);
668 }
669
670 void test_hasKnownValue_dynamic() {
671 expect(_dynamicValue().hasKnownValue, isTrue);
672 }
673
674 void test_hasKnownValue_int_known() {
675 expect(_intValue(23).hasKnownValue, isTrue);
676 }
677
678 void test_hasKnownValue_int_unknown() {
679 expect(_intValue(null).hasKnownValue, isFalse);
680 }
681
682 void test_hasKnownValue_list_empty() {
683 expect(_listValue().hasKnownValue, isTrue);
684 }
685
686 void test_hasKnownValue_list_invalidElement() {
687 expect(_listValue([_dynamicValue]).hasKnownValue, isTrue);
688 }
689
690 void test_hasKnownValue_list_valid() {
691 expect(_listValue([_intValue(23)]).hasKnownValue, isTrue);
692 }
693
694 void test_hasKnownValue_map_empty() {
695 expect(_mapValue().hasKnownValue, isTrue);
696 }
697
698 void test_hasKnownValue_map_invalidKey() {
699 expect(_mapValue([_dynamicValue(), _stringValue("value")]).hasKnownValue,
700 isTrue);
701 }
702
703 void test_hasKnownValue_map_invalidValue() {
704 expect(_mapValue([_stringValue("key"), _dynamicValue()]).hasKnownValue,
705 isTrue);
706 }
707
708 void test_hasKnownValue_map_valid() {
709 expect(
710 _mapValue([_stringValue("key"), _stringValue("value")]).hasKnownValue,
711 isTrue);
712 }
713
714 void test_hasKnownValue_null() {
715 expect(_nullValue().hasKnownValue, isTrue);
716 }
717
718 void test_hasKnownValue_num() {
719 expect(_numValue().hasKnownValue, isFalse);
720 }
721
722 void test_hasKnownValue_string_known() {
723 expect(_stringValue("twenty-three").hasKnownValue, isTrue);
724 }
725
726 void test_hasKnownValue_string_unknown() {
727 expect(_stringValue(null).hasKnownValue, isFalse);
728 }
729
730 void test_identical_bool_false() {
731 _assertIdentical(_boolValue(false), _boolValue(false), _boolValue(true));
732 }
733
734 void test_identical_bool_true() {
735 _assertIdentical(_boolValue(true), _boolValue(true), _boolValue(true));
736 }
737
738 void test_identical_bool_unknown() {
739 _assertIdentical(_boolValue(null), _boolValue(null), _boolValue(false));
740 }
741
742 void test_identical_double_false() {
743 _assertIdentical(_boolValue(false), _doubleValue(2.0), _doubleValue(4.0));
744 }
745
746 void test_identical_double_true() {
747 _assertIdentical(_boolValue(true), _doubleValue(2.0), _doubleValue(2.0));
748 }
749
750 void test_identical_double_unknown() {
751 _assertIdentical(_boolValue(null), _doubleValue(1.0), _doubleValue(null));
752 }
753
754 void test_identical_int_false() {
755 _assertIdentical(_boolValue(false), _intValue(-5), _intValue(5));
756 }
757
758 void test_identical_int_true() {
759 _assertIdentical(_boolValue(true), _intValue(5), _intValue(5));
760 }
761
762 void test_identical_int_unknown() {
763 _assertIdentical(_boolValue(null), _intValue(null), _intValue(3));
764 }
765
766 void test_identical_list_empty() {
767 _assertIdentical(_boolValue(true), _listValue(), _listValue());
768 }
769
770 void test_identical_list_false() {
771 _assertIdentical(
772 _boolValue(false), _listValue(), _listValue([_intValue(3)]));
773 }
774
775 void test_identical_map_empty() {
776 _assertIdentical(_boolValue(true), _mapValue(), _mapValue());
777 }
778
779 void test_identical_map_false() {
780 _assertIdentical(_boolValue(false), _mapValue(),
781 _mapValue([_intValue(1), _intValue(2)]));
782 }
783
784 void test_identical_null() {
785 _assertIdentical(_boolValue(true), _nullValue(), _nullValue());
786 }
787
788 void test_identical_string_false() {
789 _assertIdentical(
790 _boolValue(false), _stringValue("abc"), _stringValue("def"));
791 }
792
793 void test_identical_string_true() {
794 _assertIdentical(
795 _boolValue(true), _stringValue("abc"), _stringValue("abc"));
796 }
797
798 void test_identical_string_unknown() {
799 _assertIdentical(_boolValue(null), _stringValue(null), _stringValue("def"));
800 }
801
802 void test_integerDivide_knownDouble_knownDouble() {
803 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _doubleValue(2.0));
804 }
805
806 void test_integerDivide_knownDouble_knownInt() {
807 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _intValue(2));
808 }
809
810 void test_integerDivide_knownDouble_unknownDouble() {
811 _assertIntegerDivide(
812 _intValue(null), _doubleValue(6.0), _doubleValue(null));
813 }
814
815 void test_integerDivide_knownDouble_unknownInt() {
816 _assertIntegerDivide(_intValue(null), _doubleValue(6.0), _intValue(null));
817 }
818
819 void test_integerDivide_knownInt_knownInt() {
820 _assertIntegerDivide(_intValue(3), _intValue(6), _intValue(2));
821 }
822
823 void test_integerDivide_knownInt_knownString() {
824 _assertIntegerDivide(null, _intValue(6), _stringValue("2"));
825 }
826
827 void test_integerDivide_knownInt_unknownDouble() {
828 _assertIntegerDivide(_intValue(null), _intValue(6), _doubleValue(null));
829 }
830
831 void test_integerDivide_knownInt_unknownInt() {
832 _assertIntegerDivide(_intValue(null), _intValue(6), _intValue(null));
833 }
834
835 void test_integerDivide_knownString_knownInt() {
836 _assertIntegerDivide(null, _stringValue("6"), _intValue(2));
837 }
838
839 void test_integerDivide_unknownDouble_knownDouble() {
840 _assertIntegerDivide(
841 _intValue(null), _doubleValue(null), _doubleValue(2.0));
842 }
843
844 void test_integerDivide_unknownDouble_knownInt() {
845 _assertIntegerDivide(_intValue(null), _doubleValue(null), _intValue(2));
846 }
847
848 void test_integerDivide_unknownInt_knownDouble() {
849 _assertIntegerDivide(_intValue(null), _intValue(null), _doubleValue(2.0));
850 }
851
852 void test_integerDivide_unknownInt_knownInt() {
853 _assertIntegerDivide(_intValue(null), _intValue(null), _intValue(2));
854 }
855
856 void test_isBoolNumStringOrNull_bool_false() {
857 expect(_boolValue(false).isBoolNumStringOrNull, isTrue);
858 }
859
860 void test_isBoolNumStringOrNull_bool_true() {
861 expect(_boolValue(true).isBoolNumStringOrNull, isTrue);
862 }
863
864 void test_isBoolNumStringOrNull_bool_unknown() {
865 expect(_boolValue(null).isBoolNumStringOrNull, isTrue);
866 }
867
868 void test_isBoolNumStringOrNull_double_known() {
869 expect(_doubleValue(2.3).isBoolNumStringOrNull, isTrue);
870 }
871
872 void test_isBoolNumStringOrNull_double_unknown() {
873 expect(_doubleValue(null).isBoolNumStringOrNull, isTrue);
874 }
875
876 void test_isBoolNumStringOrNull_dynamic() {
877 expect(_dynamicValue().isBoolNumStringOrNull, isTrue);
878 }
879
880 void test_isBoolNumStringOrNull_int_known() {
881 expect(_intValue(23).isBoolNumStringOrNull, isTrue);
882 }
883
884 void test_isBoolNumStringOrNull_int_unknown() {
885 expect(_intValue(null).isBoolNumStringOrNull, isTrue);
886 }
887
888 void test_isBoolNumStringOrNull_list() {
889 expect(_listValue().isBoolNumStringOrNull, isFalse);
890 }
891
892 void test_isBoolNumStringOrNull_null() {
893 expect(_nullValue().isBoolNumStringOrNull, isTrue);
894 }
895
896 void test_isBoolNumStringOrNull_num() {
897 expect(_numValue().isBoolNumStringOrNull, isTrue);
898 }
899
900 void test_isBoolNumStringOrNull_string_known() {
901 expect(_stringValue("twenty-three").isBoolNumStringOrNull, isTrue);
902 }
903
904 void test_isBoolNumStringOrNull_string_unknown() {
905 expect(_stringValue(null).isBoolNumStringOrNull, isTrue);
906 }
907
908 void test_lessThan_knownDouble_knownDouble_false() {
909 _assertLessThan(_boolValue(false), _doubleValue(2.0), _doubleValue(1.0));
910 }
911
912 void test_lessThan_knownDouble_knownDouble_true() {
913 _assertLessThan(_boolValue(true), _doubleValue(1.0), _doubleValue(2.0));
914 }
915
916 void test_lessThan_knownDouble_knownInt_false() {
917 _assertLessThan(_boolValue(false), _doubleValue(2.0), _intValue(1));
918 }
919
920 void test_lessThan_knownDouble_knownInt_true() {
921 _assertLessThan(_boolValue(true), _doubleValue(1.0), _intValue(2));
922 }
923
924 void test_lessThan_knownDouble_unknownDouble() {
925 _assertLessThan(_boolValue(null), _doubleValue(1.0), _doubleValue(null));
926 }
927
928 void test_lessThan_knownDouble_unknownInt() {
929 _assertLessThan(_boolValue(null), _doubleValue(1.0), _intValue(null));
930 }
931
932 void test_lessThan_knownInt_knownInt_false() {
933 _assertLessThan(_boolValue(false), _intValue(2), _intValue(1));
934 }
935
936 void test_lessThan_knownInt_knownInt_true() {
937 _assertLessThan(_boolValue(true), _intValue(1), _intValue(2));
938 }
939
940 void test_lessThan_knownInt_knownString() {
941 _assertLessThan(null, _intValue(1), _stringValue("2"));
942 }
943
944 void test_lessThan_knownInt_unknownDouble() {
945 _assertLessThan(_boolValue(null), _intValue(1), _doubleValue(null));
946 }
947
948 void test_lessThan_knownInt_unknownInt() {
949 _assertLessThan(_boolValue(null), _intValue(1), _intValue(null));
950 }
951
952 void test_lessThan_knownString_knownInt() {
953 _assertLessThan(null, _stringValue("1"), _intValue(2));
954 }
955
956 void test_lessThan_unknownDouble_knownDouble() {
957 _assertLessThan(_boolValue(null), _doubleValue(null), _doubleValue(2.0));
958 }
959
960 void test_lessThan_unknownDouble_knownInt() {
961 _assertLessThan(_boolValue(null), _doubleValue(null), _intValue(2));
962 }
963
964 void test_lessThan_unknownInt_knownDouble() {
965 _assertLessThan(_boolValue(null), _intValue(null), _doubleValue(2.0));
966 }
967
968 void test_lessThan_unknownInt_knownInt() {
969 _assertLessThan(_boolValue(null), _intValue(null), _intValue(2));
970 }
971
972 void test_lessThanOrEqual_knownDouble_knownDouble_false() {
973 _assertLessThanOrEqual(
974 _boolValue(false), _doubleValue(2.0), _doubleValue(1.0));
975 }
976
977 void test_lessThanOrEqual_knownDouble_knownDouble_true() {
978 _assertLessThanOrEqual(
979 _boolValue(true), _doubleValue(1.0), _doubleValue(2.0));
980 }
981
982 void test_lessThanOrEqual_knownDouble_knownInt_false() {
983 _assertLessThanOrEqual(_boolValue(false), _doubleValue(2.0), _intValue(1));
984 }
985
986 void test_lessThanOrEqual_knownDouble_knownInt_true() {
987 _assertLessThanOrEqual(_boolValue(true), _doubleValue(1.0), _intValue(2));
988 }
989
990 void test_lessThanOrEqual_knownDouble_unknownDouble() {
991 _assertLessThanOrEqual(
992 _boolValue(null), _doubleValue(1.0), _doubleValue(null));
993 }
994
995 void test_lessThanOrEqual_knownDouble_unknownInt() {
996 _assertLessThanOrEqual(
997 _boolValue(null), _doubleValue(1.0), _intValue(null));
998 }
999
1000 void test_lessThanOrEqual_knownInt_knownInt_false() {
1001 _assertLessThanOrEqual(_boolValue(false), _intValue(2), _intValue(1));
1002 }
1003
1004 void test_lessThanOrEqual_knownInt_knownInt_true() {
1005 _assertLessThanOrEqual(_boolValue(true), _intValue(1), _intValue(2));
1006 }
1007
1008 void test_lessThanOrEqual_knownInt_knownString() {
1009 _assertLessThanOrEqual(null, _intValue(1), _stringValue("2"));
1010 }
1011
1012 void test_lessThanOrEqual_knownInt_unknownDouble() {
1013 _assertLessThanOrEqual(_boolValue(null), _intValue(1), _doubleValue(null));
1014 }
1015
1016 void test_lessThanOrEqual_knownInt_unknownInt() {
1017 _assertLessThanOrEqual(_boolValue(null), _intValue(1), _intValue(null));
1018 }
1019
1020 void test_lessThanOrEqual_knownString_knownInt() {
1021 _assertLessThanOrEqual(null, _stringValue("1"), _intValue(2));
1022 }
1023
1024 void test_lessThanOrEqual_unknownDouble_knownDouble() {
1025 _assertLessThanOrEqual(
1026 _boolValue(null), _doubleValue(null), _doubleValue(2.0));
1027 }
1028
1029 void test_lessThanOrEqual_unknownDouble_knownInt() {
1030 _assertLessThanOrEqual(_boolValue(null), _doubleValue(null), _intValue(2));
1031 }
1032
1033 void test_lessThanOrEqual_unknownInt_knownDouble() {
1034 _assertLessThanOrEqual(
1035 _boolValue(null), _intValue(null), _doubleValue(2.0));
1036 }
1037
1038 void test_lessThanOrEqual_unknownInt_knownInt() {
1039 _assertLessThanOrEqual(_boolValue(null), _intValue(null), _intValue(2));
1040 }
1041
1042 void test_logicalAnd_false_false() {
1043 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(false));
1044 }
1045
1046 void test_logicalAnd_false_null() {
1047 try {
1048 _assertLogicalAnd(_boolValue(false), _boolValue(false), _nullValue());
1049 fail("Expected EvaluationException");
1050 } on EvaluationException {}
1051 }
1052
1053 void test_logicalAnd_false_string() {
1054 try {
1055 _assertLogicalAnd(
1056 _boolValue(false), _boolValue(false), _stringValue("false"));
1057 fail("Expected EvaluationException");
1058 } on EvaluationException {}
1059 }
1060
1061 void test_logicalAnd_false_true() {
1062 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(true));
1063 }
1064
1065 void test_logicalAnd_null_false() {
1066 try {
1067 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(false));
1068 fail("Expected EvaluationException");
1069 } on EvaluationException {}
1070 }
1071
1072 void test_logicalAnd_null_true() {
1073 try {
1074 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(true));
1075 fail("Expected EvaluationException");
1076 } on EvaluationException {}
1077 }
1078
1079 void test_logicalAnd_string_false() {
1080 try {
1081 _assertLogicalAnd(
1082 _boolValue(false), _stringValue("true"), _boolValue(false));
1083 fail("Expected EvaluationException");
1084 } on EvaluationException {}
1085 }
1086
1087 void test_logicalAnd_string_true() {
1088 try {
1089 _assertLogicalAnd(
1090 _boolValue(false), _stringValue("false"), _boolValue(true));
1091 fail("Expected EvaluationException");
1092 } on EvaluationException {}
1093 }
1094
1095 void test_logicalAnd_true_false() {
1096 _assertLogicalAnd(_boolValue(false), _boolValue(true), _boolValue(false));
1097 }
1098
1099 void test_logicalAnd_true_null() {
1100 _assertLogicalAnd(null, _boolValue(true), _nullValue());
1101 }
1102
1103 void test_logicalAnd_true_string() {
1104 try {
1105 _assertLogicalAnd(
1106 _boolValue(false), _boolValue(true), _stringValue("true"));
1107 fail("Expected EvaluationException");
1108 } on EvaluationException {}
1109 }
1110
1111 void test_logicalAnd_true_true() {
1112 _assertLogicalAnd(_boolValue(true), _boolValue(true), _boolValue(true));
1113 }
1114
1115 void test_logicalNot_false() {
1116 _assertLogicalNot(_boolValue(true), _boolValue(false));
1117 }
1118
1119 void test_logicalNot_null() {
1120 _assertLogicalNot(null, _nullValue());
1121 }
1122
1123 void test_logicalNot_string() {
1124 try {
1125 _assertLogicalNot(_boolValue(true), _stringValue(null));
1126 fail("Expected EvaluationException");
1127 } on EvaluationException {}
1128 }
1129
1130 void test_logicalNot_true() {
1131 _assertLogicalNot(_boolValue(false), _boolValue(true));
1132 }
1133
1134 void test_logicalNot_unknown() {
1135 _assertLogicalNot(_boolValue(null), _boolValue(null));
1136 }
1137
1138 void test_logicalOr_false_false() {
1139 _assertLogicalOr(_boolValue(false), _boolValue(false), _boolValue(false));
1140 }
1141
1142 void test_logicalOr_false_null() {
1143 _assertLogicalOr(null, _boolValue(false), _nullValue());
1144 }
1145
1146 void test_logicalOr_false_string() {
1147 try {
1148 _assertLogicalOr(
1149 _boolValue(false), _boolValue(false), _stringValue("false"));
1150 fail("Expected EvaluationException");
1151 } on EvaluationException {}
1152 }
1153
1154 void test_logicalOr_false_true() {
1155 _assertLogicalOr(_boolValue(true), _boolValue(false), _boolValue(true));
1156 }
1157
1158 void test_logicalOr_null_false() {
1159 try {
1160 _assertLogicalOr(_boolValue(false), _nullValue(), _boolValue(false));
1161 fail("Expected EvaluationException");
1162 } on EvaluationException {}
1163 }
1164
1165 void test_logicalOr_null_true() {
1166 try {
1167 _assertLogicalOr(_boolValue(true), _nullValue(), _boolValue(true));
1168 fail("Expected EvaluationException");
1169 } on EvaluationException {}
1170 }
1171
1172 void test_logicalOr_string_false() {
1173 try {
1174 _assertLogicalOr(
1175 _boolValue(false), _stringValue("true"), _boolValue(false));
1176 fail("Expected EvaluationException");
1177 } on EvaluationException {}
1178 }
1179
1180 void test_logicalOr_string_true() {
1181 try {
1182 _assertLogicalOr(
1183 _boolValue(true), _stringValue("false"), _boolValue(true));
1184 fail("Expected EvaluationException");
1185 } on EvaluationException {}
1186 }
1187
1188 void test_logicalOr_true_false() {
1189 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(false));
1190 }
1191
1192 void test_logicalOr_true_null() {
1193 try {
1194 _assertLogicalOr(_boolValue(true), _boolValue(true), _nullValue());
1195 fail("Expected EvaluationException");
1196 } on EvaluationException {}
1197 }
1198
1199 void test_logicalOr_true_string() {
1200 try {
1201 _assertLogicalOr(
1202 _boolValue(true), _boolValue(true), _stringValue("true"));
1203 fail("Expected EvaluationException");
1204 } on EvaluationException {}
1205 }
1206
1207 void test_logicalOr_true_true() {
1208 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(true));
1209 }
1210
1211 void test_minus_knownDouble_knownDouble() {
1212 _assertMinus(_doubleValue(1.0), _doubleValue(4.0), _doubleValue(3.0));
1213 }
1214
1215 void test_minus_knownDouble_knownInt() {
1216 _assertMinus(_doubleValue(1.0), _doubleValue(4.0), _intValue(3));
1217 }
1218
1219 void test_minus_knownDouble_unknownDouble() {
1220 _assertMinus(_doubleValue(null), _doubleValue(4.0), _doubleValue(null));
1221 }
1222
1223 void test_minus_knownDouble_unknownInt() {
1224 _assertMinus(_doubleValue(null), _doubleValue(4.0), _intValue(null));
1225 }
1226
1227 void test_minus_knownInt_knownInt() {
1228 _assertMinus(_intValue(1), _intValue(4), _intValue(3));
1229 }
1230
1231 void test_minus_knownInt_knownString() {
1232 _assertMinus(null, _intValue(4), _stringValue("3"));
1233 }
1234
1235 void test_minus_knownInt_unknownDouble() {
1236 _assertMinus(_doubleValue(null), _intValue(4), _doubleValue(null));
1237 }
1238
1239 void test_minus_knownInt_unknownInt() {
1240 _assertMinus(_intValue(null), _intValue(4), _intValue(null));
1241 }
1242
1243 void test_minus_knownString_knownInt() {
1244 _assertMinus(null, _stringValue("4"), _intValue(3));
1245 }
1246
1247 void test_minus_unknownDouble_knownDouble() {
1248 _assertMinus(_doubleValue(null), _doubleValue(null), _doubleValue(3.0));
1249 }
1250
1251 void test_minus_unknownDouble_knownInt() {
1252 _assertMinus(_doubleValue(null), _doubleValue(null), _intValue(3));
1253 }
1254
1255 void test_minus_unknownInt_knownDouble() {
1256 _assertMinus(_doubleValue(null), _intValue(null), _doubleValue(3.0));
1257 }
1258
1259 void test_minus_unknownInt_knownInt() {
1260 _assertMinus(_intValue(null), _intValue(null), _intValue(3));
1261 }
1262
1263 void test_negated_double_known() {
1264 _assertNegated(_doubleValue(2.0), _doubleValue(-2.0));
1265 }
1266
1267 void test_negated_double_unknown() {
1268 _assertNegated(_doubleValue(null), _doubleValue(null));
1269 }
1270
1271 void test_negated_int_known() {
1272 _assertNegated(_intValue(-3), _intValue(3));
1273 }
1274
1275 void test_negated_int_unknown() {
1276 _assertNegated(_intValue(null), _intValue(null));
1277 }
1278
1279 void test_negated_string() {
1280 _assertNegated(null, _stringValue(null));
1281 }
1282
1283 void test_notEqual_bool_false() {
1284 _assertNotEqual(_boolValue(false), _boolValue(true), _boolValue(true));
1285 }
1286
1287 void test_notEqual_bool_true() {
1288 _assertNotEqual(_boolValue(true), _boolValue(false), _boolValue(true));
1289 }
1290
1291 void test_notEqual_bool_unknown() {
1292 _assertNotEqual(_boolValue(null), _boolValue(null), _boolValue(false));
1293 }
1294
1295 void test_notEqual_double_false() {
1296 _assertNotEqual(_boolValue(false), _doubleValue(2.0), _doubleValue(2.0));
1297 }
1298
1299 void test_notEqual_double_true() {
1300 _assertNotEqual(_boolValue(true), _doubleValue(2.0), _doubleValue(4.0));
1301 }
1302
1303 void test_notEqual_double_unknown() {
1304 _assertNotEqual(_boolValue(null), _doubleValue(1.0), _doubleValue(null));
1305 }
1306
1307 void test_notEqual_int_false() {
1308 _assertNotEqual(_boolValue(false), _intValue(5), _intValue(5));
1309 }
1310
1311 void test_notEqual_int_true() {
1312 _assertNotEqual(_boolValue(true), _intValue(-5), _intValue(5));
1313 }
1314
1315 void test_notEqual_int_unknown() {
1316 _assertNotEqual(_boolValue(null), _intValue(null), _intValue(3));
1317 }
1318
1319 void test_notEqual_null() {
1320 _assertNotEqual(_boolValue(false), _nullValue(), _nullValue());
1321 }
1322
1323 void test_notEqual_string_false() {
1324 _assertNotEqual(
1325 _boolValue(false), _stringValue("abc"), _stringValue("abc"));
1326 }
1327
1328 void test_notEqual_string_true() {
1329 _assertNotEqual(_boolValue(true), _stringValue("abc"), _stringValue("def"));
1330 }
1331
1332 void test_notEqual_string_unknown() {
1333 _assertNotEqual(_boolValue(null), _stringValue(null), _stringValue("def"));
1334 }
1335
1336 void test_performToString_bool_false() {
1337 _assertPerformToString(_stringValue("false"), _boolValue(false));
1338 }
1339
1340 void test_performToString_bool_true() {
1341 _assertPerformToString(_stringValue("true"), _boolValue(true));
1342 }
1343
1344 void test_performToString_bool_unknown() {
1345 _assertPerformToString(_stringValue(null), _boolValue(null));
1346 }
1347
1348 void test_performToString_double_known() {
1349 _assertPerformToString(_stringValue("2.0"), _doubleValue(2.0));
1350 }
1351
1352 void test_performToString_double_unknown() {
1353 _assertPerformToString(_stringValue(null), _doubleValue(null));
1354 }
1355
1356 void test_performToString_int_known() {
1357 _assertPerformToString(_stringValue("5"), _intValue(5));
1358 }
1359
1360 void test_performToString_int_unknown() {
1361 _assertPerformToString(_stringValue(null), _intValue(null));
1362 }
1363
1364 void test_performToString_null() {
1365 _assertPerformToString(_stringValue("null"), _nullValue());
1366 }
1367
1368 void test_performToString_string_known() {
1369 _assertPerformToString(_stringValue("abc"), _stringValue("abc"));
1370 }
1371
1372 void test_performToString_string_unknown() {
1373 _assertPerformToString(_stringValue(null), _stringValue(null));
1374 }
1375
1376 void test_remainder_knownDouble_knownDouble() {
1377 _assertRemainder(_doubleValue(1.0), _doubleValue(7.0), _doubleValue(2.0));
1378 }
1379
1380 void test_remainder_knownDouble_knownInt() {
1381 _assertRemainder(_doubleValue(1.0), _doubleValue(7.0), _intValue(2));
1382 }
1383
1384 void test_remainder_knownDouble_unknownDouble() {
1385 _assertRemainder(_doubleValue(null), _doubleValue(7.0), _doubleValue(null));
1386 }
1387
1388 void test_remainder_knownDouble_unknownInt() {
1389 _assertRemainder(_doubleValue(null), _doubleValue(6.0), _intValue(null));
1390 }
1391
1392 void test_remainder_knownInt_knownInt() {
1393 _assertRemainder(_intValue(1), _intValue(7), _intValue(2));
1394 }
1395
1396 void test_remainder_knownInt_knownString() {
1397 _assertRemainder(null, _intValue(7), _stringValue("2"));
1398 }
1399
1400 void test_remainder_knownInt_unknownDouble() {
1401 _assertRemainder(_doubleValue(null), _intValue(7), _doubleValue(null));
1402 }
1403
1404 void test_remainder_knownInt_unknownInt() {
1405 _assertRemainder(_intValue(null), _intValue(7), _intValue(null));
1406 }
1407
1408 void test_remainder_knownString_knownInt() {
1409 _assertRemainder(null, _stringValue("7"), _intValue(2));
1410 }
1411
1412 void test_remainder_unknownDouble_knownDouble() {
1413 _assertRemainder(_doubleValue(null), _doubleValue(null), _doubleValue(2.0));
1414 }
1415
1416 void test_remainder_unknownDouble_knownInt() {
1417 _assertRemainder(_doubleValue(null), _doubleValue(null), _intValue(2));
1418 }
1419
1420 void test_remainder_unknownInt_knownDouble() {
1421 _assertRemainder(_doubleValue(null), _intValue(null), _doubleValue(2.0));
1422 }
1423
1424 void test_remainder_unknownInt_knownInt() {
1425 _assertRemainder(_intValue(null), _intValue(null), _intValue(2));
1426 }
1427
1428 void test_shiftLeft_knownInt_knownInt() {
1429 _assertShiftLeft(_intValue(48), _intValue(6), _intValue(3));
1430 }
1431
1432 void test_shiftLeft_knownInt_knownString() {
1433 _assertShiftLeft(null, _intValue(6), _stringValue(null));
1434 }
1435
1436 void test_shiftLeft_knownInt_tooLarge() {
1437 _assertShiftLeft(
1438 _intValue(null),
1439 _intValue(6),
1440 new DartObjectImpl(
1441 _typeProvider.intType, new IntState(LONG_MAX_VALUE)));
1442 }
1443
1444 void test_shiftLeft_knownInt_unknownInt() {
1445 _assertShiftLeft(_intValue(null), _intValue(6), _intValue(null));
1446 }
1447
1448 void test_shiftLeft_knownString_knownInt() {
1449 _assertShiftLeft(null, _stringValue(null), _intValue(3));
1450 }
1451
1452 void test_shiftLeft_unknownInt_knownInt() {
1453 _assertShiftLeft(_intValue(null), _intValue(null), _intValue(3));
1454 }
1455
1456 void test_shiftLeft_unknownInt_unknownInt() {
1457 _assertShiftLeft(_intValue(null), _intValue(null), _intValue(null));
1458 }
1459
1460 void test_shiftRight_knownInt_knownInt() {
1461 _assertShiftRight(_intValue(6), _intValue(48), _intValue(3));
1462 }
1463
1464 void test_shiftRight_knownInt_knownString() {
1465 _assertShiftRight(null, _intValue(48), _stringValue(null));
1466 }
1467
1468 void test_shiftRight_knownInt_tooLarge() {
1469 _assertShiftRight(
1470 _intValue(null),
1471 _intValue(48),
1472 new DartObjectImpl(
1473 _typeProvider.intType, new IntState(LONG_MAX_VALUE)));
1474 }
1475
1476 void test_shiftRight_knownInt_unknownInt() {
1477 _assertShiftRight(_intValue(null), _intValue(48), _intValue(null));
1478 }
1479
1480 void test_shiftRight_knownString_knownInt() {
1481 _assertShiftRight(null, _stringValue(null), _intValue(3));
1482 }
1483
1484 void test_shiftRight_unknownInt_knownInt() {
1485 _assertShiftRight(_intValue(null), _intValue(null), _intValue(3));
1486 }
1487
1488 void test_shiftRight_unknownInt_unknownInt() {
1489 _assertShiftRight(_intValue(null), _intValue(null), _intValue(null));
1490 }
1491
1492 void test_stringLength_int() {
1493 try {
1494 _assertStringLength(_intValue(null), _intValue(0));
1495 fail("Expected EvaluationException");
1496 } on EvaluationException {}
1497 }
1498
1499 void test_stringLength_knownString() {
1500 _assertStringLength(_intValue(3), _stringValue("abc"));
1501 }
1502
1503 void test_stringLength_unknownString() {
1504 _assertStringLength(_intValue(null), _stringValue(null));
1505 }
1506
1507 void test_times_knownDouble_knownDouble() {
1508 _assertTimes(_doubleValue(6.0), _doubleValue(2.0), _doubleValue(3.0));
1509 }
1510
1511 void test_times_knownDouble_knownInt() {
1512 _assertTimes(_doubleValue(6.0), _doubleValue(2.0), _intValue(3));
1513 }
1514
1515 void test_times_knownDouble_unknownDouble() {
1516 _assertTimes(_doubleValue(null), _doubleValue(2.0), _doubleValue(null));
1517 }
1518
1519 void test_times_knownDouble_unknownInt() {
1520 _assertTimes(_doubleValue(null), _doubleValue(2.0), _intValue(null));
1521 }
1522
1523 void test_times_knownInt_knownInt() {
1524 _assertTimes(_intValue(6), _intValue(2), _intValue(3));
1525 }
1526
1527 void test_times_knownInt_knownString() {
1528 _assertTimes(null, _intValue(2), _stringValue("3"));
1529 }
1530
1531 void test_times_knownInt_unknownDouble() {
1532 _assertTimes(_doubleValue(null), _intValue(2), _doubleValue(null));
1533 }
1534
1535 void test_times_knownInt_unknownInt() {
1536 _assertTimes(_intValue(null), _intValue(2), _intValue(null));
1537 }
1538
1539 void test_times_knownString_knownInt() {
1540 _assertTimes(null, _stringValue("2"), _intValue(3));
1541 }
1542
1543 void test_times_unknownDouble_knownDouble() {
1544 _assertTimes(_doubleValue(null), _doubleValue(null), _doubleValue(3.0));
1545 }
1546
1547 void test_times_unknownDouble_knownInt() {
1548 _assertTimes(_doubleValue(null), _doubleValue(null), _intValue(3));
1549 }
1550
1551 void test_times_unknownInt_knownDouble() {
1552 _assertTimes(_doubleValue(null), _intValue(null), _doubleValue(3.0));
1553 }
1554
1555 void test_times_unknownInt_knownInt() {
1556 _assertTimes(_intValue(null), _intValue(null), _intValue(3));
1557 }
1558
1559 /**
1560 * Assert that the result of adding the left and right operands is the expecte d value, or that the
1561 * operation throws an exception if the expected value is `null`.
1562 *
1563 * @param expected the expected result of the operation
1564 * @param leftOperand the left operand to the operation
1565 * @param rightOperand the left operand to the operation
1566 * @throws EvaluationException if the result is an exception when it should no t be
1567 */
1568 void _assertAdd(DartObjectImpl expected, DartObjectImpl leftOperand,
1569 DartObjectImpl rightOperand) {
1570 if (expected == null) {
1571 try {
1572 leftOperand.add(_typeProvider, rightOperand);
1573 fail("Expected an EvaluationException");
1574 } on EvaluationException {}
1575 } else {
1576 DartObjectImpl result = leftOperand.add(_typeProvider, rightOperand);
1577 expect(result, isNotNull);
1578 expect(result, expected);
1579 }
1580 }
1581
1582 /**
1583 * Assert that the result of bit-anding the left and right operands is the exp ected value, or that
1584 * the operation throws an exception if the expected value is `null`.
1585 *
1586 * @param expected the expected result of the operation
1587 * @param leftOperand the left operand to the operation
1588 * @param rightOperand the left operand to the operation
1589 * @throws EvaluationException if the result is an exception when it should no t be
1590 */
1591 void _assertBitAnd(DartObjectImpl expected, DartObjectImpl leftOperand,
1592 DartObjectImpl rightOperand) {
1593 if (expected == null) {
1594 try {
1595 leftOperand.bitAnd(_typeProvider, rightOperand);
1596 fail("Expected an EvaluationException");
1597 } on EvaluationException {}
1598 } else {
1599 DartObjectImpl result = leftOperand.bitAnd(_typeProvider, rightOperand);
1600 expect(result, isNotNull);
1601 expect(result, expected);
1602 }
1603 }
1604
1605 /**
1606 * Assert that the bit-not of the operand is the expected value, or that the o peration throws an
1607 * exception if the expected value is `null`.
1608 *
1609 * @param expected the expected result of the operation
1610 * @param operand the operand to the operation
1611 * @throws EvaluationException if the result is an exception when it should no t be
1612 */
1613 void _assertBitNot(DartObjectImpl expected, DartObjectImpl operand) {
1614 if (expected == null) {
1615 try {
1616 operand.bitNot(_typeProvider);
1617 fail("Expected an EvaluationException");
1618 } on EvaluationException {}
1619 } else {
1620 DartObjectImpl result = operand.bitNot(_typeProvider);
1621 expect(result, isNotNull);
1622 expect(result, expected);
1623 }
1624 }
1625
1626 /**
1627 * Assert that the result of bit-oring the left and right operands is the expe cted value, or that
1628 * the operation throws an exception if the expected value is `null`.
1629 *
1630 * @param expected the expected result of the operation
1631 * @param leftOperand the left operand to the operation
1632 * @param rightOperand the left operand to the operation
1633 * @throws EvaluationException if the result is an exception when it should no t be
1634 */
1635 void _assertBitOr(DartObjectImpl expected, DartObjectImpl leftOperand,
1636 DartObjectImpl rightOperand) {
1637 if (expected == null) {
1638 try {
1639 leftOperand.bitOr(_typeProvider, rightOperand);
1640 fail("Expected an EvaluationException");
1641 } on EvaluationException {}
1642 } else {
1643 DartObjectImpl result = leftOperand.bitOr(_typeProvider, rightOperand);
1644 expect(result, isNotNull);
1645 expect(result, expected);
1646 }
1647 }
1648
1649 /**
1650 * Assert that the result of bit-xoring the left and right operands is the exp ected value, or that
1651 * the operation throws an exception if the expected value is `null`.
1652 *
1653 * @param expected the expected result of the operation
1654 * @param leftOperand the left operand to the operation
1655 * @param rightOperand the left operand to the operation
1656 * @throws EvaluationException if the result is an exception when it should no t be
1657 */
1658 void _assertBitXor(DartObjectImpl expected, DartObjectImpl leftOperand,
1659 DartObjectImpl rightOperand) {
1660 if (expected == null) {
1661 try {
1662 leftOperand.bitXor(_typeProvider, rightOperand);
1663 fail("Expected an EvaluationException");
1664 } on EvaluationException {}
1665 } else {
1666 DartObjectImpl result = leftOperand.bitXor(_typeProvider, rightOperand);
1667 expect(result, isNotNull);
1668 expect(result, expected);
1669 }
1670 }
1671
1672 /**
1673 * Assert that the result of concatenating the left and right operands is the expected value, or
1674 * that the operation throws an exception if the expected value is `null`.
1675 *
1676 * @param expected the expected result of the operation
1677 * @param leftOperand the left operand to the operation
1678 * @param rightOperand the left operand to the operation
1679 * @throws EvaluationException if the result is an exception when it should no t be
1680 */
1681 void _assertConcatenate(DartObjectImpl expected, DartObjectImpl leftOperand,
1682 DartObjectImpl rightOperand) {
1683 if (expected == null) {
1684 try {
1685 leftOperand.concatenate(_typeProvider, rightOperand);
1686 fail("Expected an EvaluationException");
1687 } on EvaluationException {}
1688 } else {
1689 DartObjectImpl result =
1690 leftOperand.concatenate(_typeProvider, rightOperand);
1691 expect(result, isNotNull);
1692 expect(result, expected);
1693 }
1694 }
1695
1696 /**
1697 * Assert that the result of dividing the left and right operands is the expec ted value, or that
1698 * the operation throws an exception if the expected value is `null`.
1699 *
1700 * @param expected the expected result of the operation
1701 * @param leftOperand the left operand to the operation
1702 * @param rightOperand the left operand to the operation
1703 * @throws EvaluationException if the result is an exception when it should no t be
1704 */
1705 void _assertDivide(DartObjectImpl expected, DartObjectImpl leftOperand,
1706 DartObjectImpl rightOperand) {
1707 if (expected == null) {
1708 try {
1709 leftOperand.divide(_typeProvider, rightOperand);
1710 fail("Expected an EvaluationException");
1711 } on EvaluationException {}
1712 } else {
1713 DartObjectImpl result = leftOperand.divide(_typeProvider, rightOperand);
1714 expect(result, isNotNull);
1715 expect(result, expected);
1716 }
1717 }
1718
1719 /**
1720 * Assert that the result of comparing the left and right operands for equalit y is the expected
1721 * value, or that the operation throws an exception if the expected value is ` null`.
1722 *
1723 * @param expected the expected result of the operation
1724 * @param leftOperand the left operand to the operation
1725 * @param rightOperand the left operand to the operation
1726 * @throws EvaluationException if the result is an exception when it should no t be
1727 */
1728 void _assertEqualEqual(DartObjectImpl expected, DartObjectImpl leftOperand,
1729 DartObjectImpl rightOperand) {
1730 if (expected == null) {
1731 try {
1732 leftOperand.equalEqual(_typeProvider, rightOperand);
1733 fail("Expected an EvaluationException");
1734 } on EvaluationException {}
1735 } else {
1736 DartObjectImpl result =
1737 leftOperand.equalEqual(_typeProvider, rightOperand);
1738 expect(result, isNotNull);
1739 expect(result, expected);
1740 }
1741 }
1742
1743 /**
1744 * Assert that the result of comparing the left and right operands is the expe cted value, or that
1745 * the operation throws an exception if the expected value is `null`.
1746 *
1747 * @param expected the expected result of the operation
1748 * @param leftOperand the left operand to the operation
1749 * @param rightOperand the left operand to the operation
1750 * @throws EvaluationException if the result is an exception when it should no t be
1751 */
1752 void _assertGreaterThan(DartObjectImpl expected, DartObjectImpl leftOperand,
1753 DartObjectImpl rightOperand) {
1754 if (expected == null) {
1755 try {
1756 leftOperand.greaterThan(_typeProvider, rightOperand);
1757 fail("Expected an EvaluationException");
1758 } on EvaluationException {}
1759 } else {
1760 DartObjectImpl result =
1761 leftOperand.greaterThan(_typeProvider, rightOperand);
1762 expect(result, isNotNull);
1763 expect(result, expected);
1764 }
1765 }
1766
1767 /**
1768 * Assert that the result of comparing the left and right operands is the expe cted value, or that
1769 * the operation throws an exception if the expected value is `null`.
1770 *
1771 * @param expected the expected result of the operation
1772 * @param leftOperand the left operand to the operation
1773 * @param rightOperand the left operand to the operation
1774 * @throws EvaluationException if the result is an exception when it should no t be
1775 */
1776 void _assertGreaterThanOrEqual(DartObjectImpl expected,
1777 DartObjectImpl leftOperand, DartObjectImpl rightOperand) {
1778 if (expected == null) {
1779 try {
1780 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand);
1781 fail("Expected an EvaluationException");
1782 } on EvaluationException {}
1783 } else {
1784 DartObjectImpl result =
1785 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand);
1786 expect(result, isNotNull);
1787 expect(result, expected);
1788 }
1789 }
1790
1791 /**
1792 * Assert that the result of comparing the left and right operands using
1793 * identical() is the expected value.
1794 *
1795 * @param expected the expected result of the operation
1796 * @param leftOperand the left operand to the operation
1797 * @param rightOperand the left operand to the operation
1798 */
1799 void _assertIdentical(DartObjectImpl expected, DartObjectImpl leftOperand,
1800 DartObjectImpl rightOperand) {
1801 DartObjectImpl result =
1802 leftOperand.isIdentical(_typeProvider, rightOperand);
1803 expect(result, isNotNull);
1804 expect(result, expected);
1805 }
1806
1807 void _assertInstanceOfObjectArray(Object result) {
1808 // TODO(scheglov) implement
1809 }
1810
1811 /**
1812 * Assert that the result of dividing the left and right operands as integers is the expected
1813 * value, or that the operation throws an exception if the expected value is ` null`.
1814 *
1815 * @param expected the expected result of the operation
1816 * @param leftOperand the left operand to the operation
1817 * @param rightOperand the left operand to the operation
1818 * @throws EvaluationException if the result is an exception when it should no t be
1819 */
1820 void _assertIntegerDivide(DartObjectImpl expected, DartObjectImpl leftOperand,
1821 DartObjectImpl rightOperand) {
1822 if (expected == null) {
1823 try {
1824 leftOperand.integerDivide(_typeProvider, rightOperand);
1825 fail("Expected an EvaluationException");
1826 } on EvaluationException {}
1827 } else {
1828 DartObjectImpl result =
1829 leftOperand.integerDivide(_typeProvider, rightOperand);
1830 expect(result, isNotNull);
1831 expect(result, expected);
1832 }
1833 }
1834
1835 /**
1836 * Assert that the result of comparing the left and right operands is the expe cted value, or that
1837 * the operation throws an exception if the expected value is `null`.
1838 *
1839 * @param expected the expected result of the operation
1840 * @param leftOperand the left operand to the operation
1841 * @param rightOperand the left operand to the operation
1842 * @throws EvaluationException if the result is an exception when it should no t be
1843 */
1844 void _assertLessThan(DartObjectImpl expected, DartObjectImpl leftOperand,
1845 DartObjectImpl rightOperand) {
1846 if (expected == null) {
1847 try {
1848 leftOperand.lessThan(_typeProvider, rightOperand);
1849 fail("Expected an EvaluationException");
1850 } on EvaluationException {}
1851 } else {
1852 DartObjectImpl result = leftOperand.lessThan(_typeProvider, rightOperand);
1853 expect(result, isNotNull);
1854 expect(result, expected);
1855 }
1856 }
1857
1858 /**
1859 * Assert that the result of comparing the left and right operands is the expe cted value, or that
1860 * the operation throws an exception if the expected value is `null`.
1861 *
1862 * @param expected the expected result of the operation
1863 * @param leftOperand the left operand to the operation
1864 * @param rightOperand the left operand to the operation
1865 * @throws EvaluationException if the result is an exception when it should no t be
1866 */
1867 void _assertLessThanOrEqual(DartObjectImpl expected,
1868 DartObjectImpl leftOperand, DartObjectImpl rightOperand) {
1869 if (expected == null) {
1870 try {
1871 leftOperand.lessThanOrEqual(_typeProvider, rightOperand);
1872 fail("Expected an EvaluationException");
1873 } on EvaluationException {}
1874 } else {
1875 DartObjectImpl result =
1876 leftOperand.lessThanOrEqual(_typeProvider, rightOperand);
1877 expect(result, isNotNull);
1878 expect(result, expected);
1879 }
1880 }
1881
1882 /**
1883 * Assert that the result of logical-anding the left and right operands is the expected value, or
1884 * that the operation throws an exception if the expected value is `null`.
1885 *
1886 * @param expected the expected result of the operation
1887 * @param leftOperand the left operand to the operation
1888 * @param rightOperand the left operand to the operation
1889 * @throws EvaluationException if the result is an exception when it should no t be
1890 */
1891 void _assertLogicalAnd(DartObjectImpl expected, DartObjectImpl leftOperand,
1892 DartObjectImpl rightOperand) {
1893 if (expected == null) {
1894 try {
1895 leftOperand.logicalAnd(_typeProvider, rightOperand);
1896 fail("Expected an EvaluationException");
1897 } on EvaluationException {}
1898 } else {
1899 DartObjectImpl result =
1900 leftOperand.logicalAnd(_typeProvider, rightOperand);
1901 expect(result, isNotNull);
1902 expect(result, expected);
1903 }
1904 }
1905
1906 /**
1907 * Assert that the logical-not of the operand is the expected value, or that t he operation throws
1908 * an exception if the expected value is `null`.
1909 *
1910 * @param expected the expected result of the operation
1911 * @param operand the operand to the operation
1912 * @throws EvaluationException if the result is an exception when it should no t be
1913 */
1914 void _assertLogicalNot(DartObjectImpl expected, DartObjectImpl operand) {
1915 if (expected == null) {
1916 try {
1917 operand.logicalNot(_typeProvider);
1918 fail("Expected an EvaluationException");
1919 } on EvaluationException {}
1920 } else {
1921 DartObjectImpl result = operand.logicalNot(_typeProvider);
1922 expect(result, isNotNull);
1923 expect(result, expected);
1924 }
1925 }
1926
1927 /**
1928 * Assert that the result of logical-oring the left and right operands is the expected value, or
1929 * that the operation throws an exception if the expected value is `null`.
1930 *
1931 * @param expected the expected result of the operation
1932 * @param leftOperand the left operand to the operation
1933 * @param rightOperand the left operand to the operation
1934 * @throws EvaluationException if the result is an exception when it should no t be
1935 */
1936 void _assertLogicalOr(DartObjectImpl expected, DartObjectImpl leftOperand,
1937 DartObjectImpl rightOperand) {
1938 if (expected == null) {
1939 try {
1940 leftOperand.logicalOr(_typeProvider, rightOperand);
1941 fail("Expected an EvaluationException");
1942 } on EvaluationException {}
1943 } else {
1944 DartObjectImpl result =
1945 leftOperand.logicalOr(_typeProvider, rightOperand);
1946 expect(result, isNotNull);
1947 expect(result, expected);
1948 }
1949 }
1950
1951 /**
1952 * Assert that the result of subtracting the left and right operands is the ex pected value, or
1953 * that the operation throws an exception if the expected value is `null`.
1954 *
1955 * @param expected the expected result of the operation
1956 * @param leftOperand the left operand to the operation
1957 * @param rightOperand the left operand to the operation
1958 * @throws EvaluationException if the result is an exception when it should no t be
1959 */
1960 void _assertMinus(DartObjectImpl expected, DartObjectImpl leftOperand,
1961 DartObjectImpl rightOperand) {
1962 if (expected == null) {
1963 try {
1964 leftOperand.minus(_typeProvider, rightOperand);
1965 fail("Expected an EvaluationException");
1966 } on EvaluationException {}
1967 } else {
1968 DartObjectImpl result = leftOperand.minus(_typeProvider, rightOperand);
1969 expect(result, isNotNull);
1970 expect(result, expected);
1971 }
1972 }
1973
1974 /**
1975 * Assert that the negation of the operand is the expected value, or that the operation throws an
1976 * exception if the expected value is `null`.
1977 *
1978 * @param expected the expected result of the operation
1979 * @param operand the operand to the operation
1980 * @throws EvaluationException if the result is an exception when it should no t be
1981 */
1982 void _assertNegated(DartObjectImpl expected, DartObjectImpl operand) {
1983 if (expected == null) {
1984 try {
1985 operand.negated(_typeProvider);
1986 fail("Expected an EvaluationException");
1987 } on EvaluationException {}
1988 } else {
1989 DartObjectImpl result = operand.negated(_typeProvider);
1990 expect(result, isNotNull);
1991 expect(result, expected);
1992 }
1993 }
1994
1995 /**
1996 * Assert that the result of comparing the left and right operands for inequal ity is the expected
1997 * value, or that the operation throws an exception if the expected value is ` null`.
1998 *
1999 * @param expected the expected result of the operation
2000 * @param leftOperand the left operand to the operation
2001 * @param rightOperand the left operand to the operation
2002 * @throws EvaluationException if the result is an exception when it should no t be
2003 */
2004 void _assertNotEqual(DartObjectImpl expected, DartObjectImpl leftOperand,
2005 DartObjectImpl rightOperand) {
2006 if (expected == null) {
2007 try {
2008 leftOperand.notEqual(_typeProvider, rightOperand);
2009 fail("Expected an EvaluationException");
2010 } on EvaluationException {}
2011 } else {
2012 DartObjectImpl result = leftOperand.notEqual(_typeProvider, rightOperand);
2013 expect(result, isNotNull);
2014 expect(result, expected);
2015 }
2016 }
2017
2018 /**
2019 * Assert that converting the operand to a string is the expected value, or th at the operation
2020 * throws an exception if the expected value is `null`.
2021 *
2022 * @param expected the expected result of the operation
2023 * @param operand the operand to the operation
2024 * @throws EvaluationException if the result is an exception when it should no t be
2025 */
2026 void _assertPerformToString(DartObjectImpl expected, DartObjectImpl operand) {
2027 if (expected == null) {
2028 try {
2029 operand.performToString(_typeProvider);
2030 fail("Expected an EvaluationException");
2031 } on EvaluationException {}
2032 } else {
2033 DartObjectImpl result = operand.performToString(_typeProvider);
2034 expect(result, isNotNull);
2035 expect(result, expected);
2036 }
2037 }
2038
2039 /**
2040 * Assert that the result of taking the remainder of the left and right operan ds is the expected
2041 * value, or that the operation throws an exception if the expected value is ` null`.
2042 *
2043 * @param expected the expected result of the operation
2044 * @param leftOperand the left operand to the operation
2045 * @param rightOperand the left operand to the operation
2046 * @throws EvaluationException if the result is an exception when it should no t be
2047 */
2048 void _assertRemainder(DartObjectImpl expected, DartObjectImpl leftOperand,
2049 DartObjectImpl rightOperand) {
2050 if (expected == null) {
2051 try {
2052 leftOperand.remainder(_typeProvider, rightOperand);
2053 fail("Expected an EvaluationException");
2054 } on EvaluationException {}
2055 } else {
2056 DartObjectImpl result =
2057 leftOperand.remainder(_typeProvider, rightOperand);
2058 expect(result, isNotNull);
2059 expect(result, expected);
2060 }
2061 }
2062
2063 /**
2064 * Assert that the result of multiplying the left and right operands is the ex pected value, or
2065 * that the operation throws an exception if the expected value is `null`.
2066 *
2067 * @param expected the expected result of the operation
2068 * @param leftOperand the left operand to the operation
2069 * @param rightOperand the left operand to the operation
2070 * @throws EvaluationException if the result is an exception when it should no t be
2071 */
2072 void _assertShiftLeft(DartObjectImpl expected, DartObjectImpl leftOperand,
2073 DartObjectImpl rightOperand) {
2074 if (expected == null) {
2075 try {
2076 leftOperand.shiftLeft(_typeProvider, rightOperand);
2077 fail("Expected an EvaluationException");
2078 } on EvaluationException {}
2079 } else {
2080 DartObjectImpl result =
2081 leftOperand.shiftLeft(_typeProvider, rightOperand);
2082 expect(result, isNotNull);
2083 expect(result, expected);
2084 }
2085 }
2086
2087 /**
2088 * Assert that the result of multiplying the left and right operands is the ex pected value, or
2089 * that the operation throws an exception if the expected value is `null`.
2090 *
2091 * @param expected the expected result of the operation
2092 * @param leftOperand the left operand to the operation
2093 * @param rightOperand the left operand to the operation
2094 * @throws EvaluationException if the result is an exception when it should no t be
2095 */
2096 void _assertShiftRight(DartObjectImpl expected, DartObjectImpl leftOperand,
2097 DartObjectImpl rightOperand) {
2098 if (expected == null) {
2099 try {
2100 leftOperand.shiftRight(_typeProvider, rightOperand);
2101 fail("Expected an EvaluationException");
2102 } on EvaluationException {}
2103 } else {
2104 DartObjectImpl result =
2105 leftOperand.shiftRight(_typeProvider, rightOperand);
2106 expect(result, isNotNull);
2107 expect(result, expected);
2108 }
2109 }
2110
2111 /**
2112 * Assert that the length of the operand is the expected value, or that the op eration throws an
2113 * exception if the expected value is `null`.
2114 *
2115 * @param expected the expected result of the operation
2116 * @param operand the operand to the operation
2117 * @throws EvaluationException if the result is an exception when it should no t be
2118 */
2119 void _assertStringLength(DartObjectImpl expected, DartObjectImpl operand) {
2120 if (expected == null) {
2121 try {
2122 operand.stringLength(_typeProvider);
2123 fail("Expected an EvaluationException");
2124 } on EvaluationException {}
2125 } else {
2126 DartObjectImpl result = operand.stringLength(_typeProvider);
2127 expect(result, isNotNull);
2128 expect(result, expected);
2129 }
2130 }
2131
2132 /**
2133 * Assert that the result of multiplying the left and right operands is the ex pected value, or
2134 * that the operation throws an exception if the expected value is `null`.
2135 *
2136 * @param expected the expected result of the operation
2137 * @param leftOperand the left operand to the operation
2138 * @param rightOperand the left operand to the operation
2139 * @throws EvaluationException if the result is an exception when it should no t be
2140 */
2141 void _assertTimes(DartObjectImpl expected, DartObjectImpl leftOperand,
2142 DartObjectImpl rightOperand) {
2143 if (expected == null) {
2144 try {
2145 leftOperand.times(_typeProvider, rightOperand);
2146 fail("Expected an EvaluationException");
2147 } on EvaluationException {}
2148 } else {
2149 DartObjectImpl result = leftOperand.times(_typeProvider, rightOperand);
2150 expect(result, isNotNull);
2151 expect(result, expected);
2152 }
2153 }
2154
2155 DartObjectImpl _boolValue(bool value) {
2156 if (value == null) {
2157 return new DartObjectImpl(
2158 _typeProvider.boolType, BoolState.UNKNOWN_VALUE);
2159 } else if (identical(value, false)) {
2160 return new DartObjectImpl(_typeProvider.boolType, BoolState.FALSE_STATE);
2161 } else if (identical(value, true)) {
2162 return new DartObjectImpl(_typeProvider.boolType, BoolState.TRUE_STATE);
2163 }
2164 fail("Invalid boolean value used in test");
2165 return null;
2166 }
2167
2168 DartObjectImpl _doubleValue(double value) {
2169 if (value == null) {
2170 return new DartObjectImpl(
2171 _typeProvider.doubleType, DoubleState.UNKNOWN_VALUE);
2172 } else {
2173 return new DartObjectImpl(
2174 _typeProvider.doubleType, new DoubleState(value));
2175 }
2176 }
2177
2178 DartObjectImpl _dynamicValue() {
2179 return new DartObjectImpl(
2180 _typeProvider.nullType, DynamicState.DYNAMIC_STATE);
2181 }
2182
2183 DartObjectImpl _intValue(int value) {
2184 if (value == null) {
2185 return new DartObjectImpl(_typeProvider.intType, IntState.UNKNOWN_VALUE);
2186 } else {
2187 return new DartObjectImpl(_typeProvider.intType, new IntState(value));
2188 }
2189 }
2190
2191 DartObjectImpl _listValue(
2192 [List<DartObjectImpl> elements = DartObjectImpl.EMPTY_LIST]) {
2193 return new DartObjectImpl(_typeProvider.listType, new ListState(elements));
2194 }
2195
2196 DartObjectImpl _mapValue(
2197 [List<DartObjectImpl> keyElementPairs = DartObjectImpl.EMPTY_LIST]) {
2198 Map<DartObjectImpl, DartObjectImpl> map =
2199 new Map<DartObjectImpl, DartObjectImpl>();
2200 int count = keyElementPairs.length;
2201 for (int i = 0; i < count;) {
2202 map[keyElementPairs[i++]] = keyElementPairs[i++];
2203 }
2204 return new DartObjectImpl(_typeProvider.mapType, new MapState(map));
2205 }
2206
2207 DartObjectImpl _nullValue() {
2208 return new DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
2209 }
2210
2211 DartObjectImpl _numValue() {
2212 return new DartObjectImpl(_typeProvider.nullType, NumState.UNKNOWN_VALUE);
2213 }
2214
2215 DartObjectImpl _stringValue(String value) {
2216 if (value == null) {
2217 return new DartObjectImpl(
2218 _typeProvider.stringType, StringState.UNKNOWN_VALUE);
2219 } else {
2220 return new DartObjectImpl(
2221 _typeProvider.stringType, new StringState(value));
2222 }
2223 }
2224
2225 DartObjectImpl _symbolValue(String value) {
2226 return new DartObjectImpl(_typeProvider.symbolType, new SymbolState(value));
2227 }
2228 }
2229
2230 @reflectiveTest
2231 class DartUriResolverTest { 104 class DartUriResolverTest {
2232 void test_creation() { 105 void test_creation() {
2233 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; 106 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
2234 expect(sdkDirectory, isNotNull); 107 expect(sdkDirectory, isNotNull);
2235 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 108 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
2236 expect(new DartUriResolver(sdk), isNotNull); 109 expect(new DartUriResolver(sdk), isNotNull);
2237 } 110 }
2238 111
2239 void test_isDartUri_null_scheme() { 112 void test_isDartUri_null_scheme() {
2240 Uri uri = parseUriWithException("foo.dart"); 113 Uri uri = parseUriWithException("foo.dart");
(...skipping 25 matching lines...) Expand all
2266 expect(sdkDirectory, isNotNull); 139 expect(sdkDirectory, isNotNull);
2267 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory); 140 DartSdk sdk = new DirectoryBasedDartSdk(sdkDirectory);
2268 UriResolver resolver = new DartUriResolver(sdk); 141 UriResolver resolver = new DartUriResolver(sdk);
2269 Source result = resolver 142 Source result = resolver
2270 .resolveAbsolute(parseUriWithException("package:some/file.dart")); 143 .resolveAbsolute(parseUriWithException("package:some/file.dart"));
2271 expect(result, isNull); 144 expect(result, isNull);
2272 } 145 }
2273 } 146 }
2274 147
2275 @reflectiveTest 148 @reflectiveTest
2276 class DeclaredVariablesTest extends EngineTestCase {
2277 void test_getBool_false() {
2278 TestTypeProvider typeProvider = new TestTypeProvider();
2279 String variableName = "var";
2280 DeclaredVariables variables = new DeclaredVariables();
2281 variables.define(variableName, "false");
2282 DartObject object = variables.getBool(typeProvider, variableName);
2283 expect(object, isNotNull);
2284 expect(object.toBoolValue(), false);
2285 }
2286
2287 void test_getBool_invalid() {
2288 TestTypeProvider typeProvider = new TestTypeProvider();
2289 String variableName = "var";
2290 DeclaredVariables variables = new DeclaredVariables();
2291 variables.define(variableName, "not true");
2292 _assertNullDartObject(
2293 typeProvider, variables.getBool(typeProvider, variableName));
2294 }
2295
2296 void test_getBool_true() {
2297 TestTypeProvider typeProvider = new TestTypeProvider();
2298 String variableName = "var";
2299 DeclaredVariables variables = new DeclaredVariables();
2300 variables.define(variableName, "true");
2301 DartObject object = variables.getBool(typeProvider, variableName);
2302 expect(object, isNotNull);
2303 expect(object.toBoolValue(), true);
2304 }
2305
2306 void test_getBool_undefined() {
2307 TestTypeProvider typeProvider = new TestTypeProvider();
2308 String variableName = "var";
2309 DeclaredVariables variables = new DeclaredVariables();
2310 _assertUnknownDartObject(
2311 typeProvider.boolType, variables.getBool(typeProvider, variableName));
2312 }
2313
2314 void test_getInt_invalid() {
2315 TestTypeProvider typeProvider = new TestTypeProvider();
2316 String variableName = "var";
2317 DeclaredVariables variables = new DeclaredVariables();
2318 variables.define(variableName, "four score and seven years");
2319 _assertNullDartObject(
2320 typeProvider, variables.getInt(typeProvider, variableName));
2321 }
2322
2323 void test_getInt_undefined() {
2324 TestTypeProvider typeProvider = new TestTypeProvider();
2325 String variableName = "var";
2326 DeclaredVariables variables = new DeclaredVariables();
2327 _assertUnknownDartObject(
2328 typeProvider.intType, variables.getInt(typeProvider, variableName));
2329 }
2330
2331 void test_getInt_valid() {
2332 TestTypeProvider typeProvider = new TestTypeProvider();
2333 String variableName = "var";
2334 DeclaredVariables variables = new DeclaredVariables();
2335 variables.define(variableName, "23");
2336 DartObject object = variables.getInt(typeProvider, variableName);
2337 expect(object, isNotNull);
2338 expect(object.toIntValue(), 23);
2339 }
2340
2341 void test_getString_defined() {
2342 TestTypeProvider typeProvider = new TestTypeProvider();
2343 String variableName = "var";
2344 String value = "value";
2345 DeclaredVariables variables = new DeclaredVariables();
2346 variables.define(variableName, value);
2347 DartObject object = variables.getString(typeProvider, variableName);
2348 expect(object, isNotNull);
2349 expect(object.toStringValue(), value);
2350 }
2351
2352 void test_getString_undefined() {
2353 TestTypeProvider typeProvider = new TestTypeProvider();
2354 String variableName = "var";
2355 DeclaredVariables variables = new DeclaredVariables();
2356 _assertUnknownDartObject(typeProvider.stringType,
2357 variables.getString(typeProvider, variableName));
2358 }
2359
2360 void _assertNullDartObject(TestTypeProvider typeProvider, DartObject result) {
2361 expect(result.type, typeProvider.nullType);
2362 }
2363
2364 void _assertUnknownDartObject(
2365 ParameterizedType expectedType, DartObject result) {
2366 expect((result as DartObjectImpl).isUnknown, isTrue);
2367 expect(result.type, expectedType);
2368 }
2369 }
2370
2371 @reflectiveTest
2372 class DirectoryBasedDartSdkTest { 149 class DirectoryBasedDartSdkTest {
2373 void fail_getDocFileFor() { 150 void fail_getDocFileFor() {
2374 DirectoryBasedDartSdk sdk = _createDartSdk(); 151 DirectoryBasedDartSdk sdk = _createDartSdk();
2375 JavaFile docFile = sdk.getDocFileFor("html"); 152 JavaFile docFile = sdk.getDocFileFor("html");
2376 expect(docFile, isNotNull); 153 expect(docFile, isNotNull);
2377 } 154 }
2378 155
2379 void test_creation() { 156 void test_creation() {
2380 DirectoryBasedDartSdk sdk = _createDartSdk(); 157 DirectoryBasedDartSdk sdk = _createDartSdk();
2381 expect(sdk, isNotNull); 158 expect(sdk, isNotNull);
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after
6038 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); 3815 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI));
6039 expect(UriKind.fromEncoding(0x58), same(null)); 3816 expect(UriKind.fromEncoding(0x58), same(null));
6040 } 3817 }
6041 3818
6042 void test_getEncoding() { 3819 void test_getEncoding() {
6043 expect(UriKind.DART_URI.encoding, 0x64); 3820 expect(UriKind.DART_URI.encoding, 0x64);
6044 expect(UriKind.FILE_URI.encoding, 0x66); 3821 expect(UriKind.FILE_URI.encoding, 0x66);
6045 expect(UriKind.PACKAGE_URI.encoding, 0x70); 3822 expect(UriKind.PACKAGE_URI.encoding, 0x70);
6046 } 3823 }
6047 } 3824 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/constant_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698