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