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