| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.constant_test; | 5 library analyzer.test.constant_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
| 11 import 'package:analyzer/src/generated/constant.dart'; | 11 import 'package:analyzer/src/generated/constant.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
| 14 import 'package:analyzer/src/generated/java_core.dart'; |
| 14 import 'package:analyzer/src/generated/resolver.dart'; | 15 import 'package:analyzer/src/generated/resolver.dart'; |
| 15 import 'package:analyzer/src/generated/scanner.dart'; | 16 import 'package:analyzer/src/generated/scanner.dart'; |
| 16 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 17 import 'package:analyzer/src/generated/source_io.dart'; | 18 import 'package:analyzer/src/generated/source_io.dart'; |
| 18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 19 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 19 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 20 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 20 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 21 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 21 import 'package:analyzer/src/generated/utilities_collection.dart'; | 22 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 22 import 'package:analyzer/src/task/dart.dart'; | 23 import 'package:analyzer/src/task/dart.dart'; |
| 23 import 'package:path/path.dart'; | 24 import 'package:path/path.dart'; |
| 24 import 'package:unittest/unittest.dart'; | 25 import 'package:unittest/unittest.dart'; |
| 25 | 26 |
| 26 import '../reflective_tests.dart'; | 27 import '../reflective_tests.dart'; |
| 27 import '../utils.dart'; | 28 import '../utils.dart'; |
| 28 import 'engine_test.dart'; | 29 import 'engine_test.dart'; |
| 29 import 'resolver_test.dart'; | 30 import 'resolver_test.dart'; |
| 30 import 'test_support.dart'; | 31 import 'test_support.dart'; |
| 31 | 32 |
| 32 main() { | 33 main() { |
| 33 initializeTestEnvironment(); | 34 initializeTestEnvironment(); |
| 34 runReflectiveTests(ConstantEvaluatorTest); | 35 runReflectiveTests(ConstantEvaluatorTest); |
| 35 runReflectiveTests(ConstantFinderTest); | 36 runReflectiveTests(ConstantFinderTest); |
| 36 runReflectiveTests(ConstantValueComputerTest); | 37 runReflectiveTests(ConstantValueComputerTest); |
| 37 runReflectiveTests(ConstantVisitorTest); | 38 runReflectiveTests(ConstantVisitorTest); |
| 39 runReflectiveTests(DartObjectImplTest); |
| 40 runReflectiveTests(DeclaredVariablesTest); |
| 38 runReflectiveTests(ReferenceFinderTest); | 41 runReflectiveTests(ReferenceFinderTest); |
| 39 } | 42 } |
| 40 | 43 |
| 41 /** | 44 /** |
| 42 * Implementation of [ConstantEvaluationValidator] used during unit tests; | 45 * Implementation of [ConstantEvaluationValidator] used during unit tests; |
| 43 * verifies that any nodes referenced during constant evaluation are present in | 46 * verifies that any nodes referenced during constant evaluation are present in |
| 44 * the dependency graph. | 47 * the dependency graph. |
| 45 */ | 48 */ |
| 46 class ConstantEvaluationValidator_ForTest | 49 class ConstantEvaluationValidator_ForTest |
| 47 implements ConstantEvaluationValidator { | 50 implements ConstantEvaluationValidator { |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 new ConstantEvaluationEngine(typeProvider, new DeclaredVariables(), | 2194 new ConstantEvaluationEngine(typeProvider, new DeclaredVariables(), |
| 2192 typeSystem: typeSystem), | 2195 typeSystem: typeSystem), |
| 2193 errorReporter, | 2196 errorReporter, |
| 2194 lexicalEnvironment: lexicalEnvironment)); | 2197 lexicalEnvironment: lexicalEnvironment)); |
| 2195 errorListener.assertNoErrors(); | 2198 errorListener.assertNoErrors(); |
| 2196 return result; | 2199 return result; |
| 2197 } | 2200 } |
| 2198 } | 2201 } |
| 2199 | 2202 |
| 2200 @reflectiveTest | 2203 @reflectiveTest |
| 2204 class DartObjectImplTest extends EngineTestCase { |
| 2205 TypeProvider _typeProvider = new TestTypeProvider(); |
| 2206 |
| 2207 void test_add_knownDouble_knownDouble() { |
| 2208 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _doubleValue(2.0)); |
| 2209 } |
| 2210 |
| 2211 void test_add_knownDouble_knownInt() { |
| 2212 _assertAdd(_doubleValue(3.0), _doubleValue(1.0), _intValue(2)); |
| 2213 } |
| 2214 |
| 2215 void test_add_knownDouble_unknownDouble() { |
| 2216 _assertAdd(_doubleValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 2217 } |
| 2218 |
| 2219 void test_add_knownDouble_unknownInt() { |
| 2220 _assertAdd(_doubleValue(null), _doubleValue(1.0), _intValue(null)); |
| 2221 } |
| 2222 |
| 2223 void test_add_knownInt_knownInt() { |
| 2224 _assertAdd(_intValue(3), _intValue(1), _intValue(2)); |
| 2225 } |
| 2226 |
| 2227 void test_add_knownInt_knownString() { |
| 2228 _assertAdd(null, _intValue(1), _stringValue("2")); |
| 2229 } |
| 2230 |
| 2231 void test_add_knownInt_unknownDouble() { |
| 2232 _assertAdd(_doubleValue(null), _intValue(1), _doubleValue(null)); |
| 2233 } |
| 2234 |
| 2235 void test_add_knownInt_unknownInt() { |
| 2236 _assertAdd(_intValue(null), _intValue(1), _intValue(null)); |
| 2237 } |
| 2238 |
| 2239 void test_add_knownString_knownInt() { |
| 2240 _assertAdd(null, _stringValue("1"), _intValue(2)); |
| 2241 } |
| 2242 |
| 2243 void test_add_knownString_knownString() { |
| 2244 _assertAdd(_stringValue("ab"), _stringValue("a"), _stringValue("b")); |
| 2245 } |
| 2246 |
| 2247 void test_add_knownString_unknownString() { |
| 2248 _assertAdd(_stringValue(null), _stringValue("a"), _stringValue(null)); |
| 2249 } |
| 2250 |
| 2251 void test_add_unknownDouble_knownDouble() { |
| 2252 _assertAdd(_doubleValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 2253 } |
| 2254 |
| 2255 void test_add_unknownDouble_knownInt() { |
| 2256 _assertAdd(_doubleValue(null), _doubleValue(null), _intValue(2)); |
| 2257 } |
| 2258 |
| 2259 void test_add_unknownInt_knownDouble() { |
| 2260 _assertAdd(_doubleValue(null), _intValue(null), _doubleValue(2.0)); |
| 2261 } |
| 2262 |
| 2263 void test_add_unknownInt_knownInt() { |
| 2264 _assertAdd(_intValue(null), _intValue(null), _intValue(2)); |
| 2265 } |
| 2266 |
| 2267 void test_add_unknownString_knownString() { |
| 2268 _assertAdd(_stringValue(null), _stringValue(null), _stringValue("b")); |
| 2269 } |
| 2270 |
| 2271 void test_add_unknownString_unknownString() { |
| 2272 _assertAdd(_stringValue(null), _stringValue(null), _stringValue(null)); |
| 2273 } |
| 2274 |
| 2275 void test_bitAnd_knownInt_knownInt() { |
| 2276 _assertBitAnd(_intValue(2), _intValue(6), _intValue(3)); |
| 2277 } |
| 2278 |
| 2279 void test_bitAnd_knownInt_knownString() { |
| 2280 _assertBitAnd(null, _intValue(6), _stringValue("3")); |
| 2281 } |
| 2282 |
| 2283 void test_bitAnd_knownInt_unknownInt() { |
| 2284 _assertBitAnd(_intValue(null), _intValue(6), _intValue(null)); |
| 2285 } |
| 2286 |
| 2287 void test_bitAnd_knownString_knownInt() { |
| 2288 _assertBitAnd(null, _stringValue("6"), _intValue(3)); |
| 2289 } |
| 2290 |
| 2291 void test_bitAnd_unknownInt_knownInt() { |
| 2292 _assertBitAnd(_intValue(null), _intValue(null), _intValue(3)); |
| 2293 } |
| 2294 |
| 2295 void test_bitAnd_unknownInt_unknownInt() { |
| 2296 _assertBitAnd(_intValue(null), _intValue(null), _intValue(null)); |
| 2297 } |
| 2298 |
| 2299 void test_bitNot_knownInt() { |
| 2300 _assertBitNot(_intValue(-4), _intValue(3)); |
| 2301 } |
| 2302 |
| 2303 void test_bitNot_knownString() { |
| 2304 _assertBitNot(null, _stringValue("6")); |
| 2305 } |
| 2306 |
| 2307 void test_bitNot_unknownInt() { |
| 2308 _assertBitNot(_intValue(null), _intValue(null)); |
| 2309 } |
| 2310 |
| 2311 void test_bitOr_knownInt_knownInt() { |
| 2312 _assertBitOr(_intValue(7), _intValue(6), _intValue(3)); |
| 2313 } |
| 2314 |
| 2315 void test_bitOr_knownInt_knownString() { |
| 2316 _assertBitOr(null, _intValue(6), _stringValue("3")); |
| 2317 } |
| 2318 |
| 2319 void test_bitOr_knownInt_unknownInt() { |
| 2320 _assertBitOr(_intValue(null), _intValue(6), _intValue(null)); |
| 2321 } |
| 2322 |
| 2323 void test_bitOr_knownString_knownInt() { |
| 2324 _assertBitOr(null, _stringValue("6"), _intValue(3)); |
| 2325 } |
| 2326 |
| 2327 void test_bitOr_unknownInt_knownInt() { |
| 2328 _assertBitOr(_intValue(null), _intValue(null), _intValue(3)); |
| 2329 } |
| 2330 |
| 2331 void test_bitOr_unknownInt_unknownInt() { |
| 2332 _assertBitOr(_intValue(null), _intValue(null), _intValue(null)); |
| 2333 } |
| 2334 |
| 2335 void test_bitXor_knownInt_knownInt() { |
| 2336 _assertBitXor(_intValue(5), _intValue(6), _intValue(3)); |
| 2337 } |
| 2338 |
| 2339 void test_bitXor_knownInt_knownString() { |
| 2340 _assertBitXor(null, _intValue(6), _stringValue("3")); |
| 2341 } |
| 2342 |
| 2343 void test_bitXor_knownInt_unknownInt() { |
| 2344 _assertBitXor(_intValue(null), _intValue(6), _intValue(null)); |
| 2345 } |
| 2346 |
| 2347 void test_bitXor_knownString_knownInt() { |
| 2348 _assertBitXor(null, _stringValue("6"), _intValue(3)); |
| 2349 } |
| 2350 |
| 2351 void test_bitXor_unknownInt_knownInt() { |
| 2352 _assertBitXor(_intValue(null), _intValue(null), _intValue(3)); |
| 2353 } |
| 2354 |
| 2355 void test_bitXor_unknownInt_unknownInt() { |
| 2356 _assertBitXor(_intValue(null), _intValue(null), _intValue(null)); |
| 2357 } |
| 2358 |
| 2359 void test_concatenate_knownInt_knownString() { |
| 2360 _assertConcatenate(null, _intValue(2), _stringValue("def")); |
| 2361 } |
| 2362 |
| 2363 void test_concatenate_knownString_knownInt() { |
| 2364 _assertConcatenate(null, _stringValue("abc"), _intValue(3)); |
| 2365 } |
| 2366 |
| 2367 void test_concatenate_knownString_knownString() { |
| 2368 _assertConcatenate( |
| 2369 _stringValue("abcdef"), _stringValue("abc"), _stringValue("def")); |
| 2370 } |
| 2371 |
| 2372 void test_concatenate_knownString_unknownString() { |
| 2373 _assertConcatenate( |
| 2374 _stringValue(null), _stringValue("abc"), _stringValue(null)); |
| 2375 } |
| 2376 |
| 2377 void test_concatenate_unknownString_knownString() { |
| 2378 _assertConcatenate( |
| 2379 _stringValue(null), _stringValue(null), _stringValue("def")); |
| 2380 } |
| 2381 |
| 2382 void test_divide_knownDouble_knownDouble() { |
| 2383 _assertDivide(_doubleValue(3.0), _doubleValue(6.0), _doubleValue(2.0)); |
| 2384 } |
| 2385 |
| 2386 void test_divide_knownDouble_knownInt() { |
| 2387 _assertDivide(_doubleValue(3.0), _doubleValue(6.0), _intValue(2)); |
| 2388 } |
| 2389 |
| 2390 void test_divide_knownDouble_unknownDouble() { |
| 2391 _assertDivide(_doubleValue(null), _doubleValue(6.0), _doubleValue(null)); |
| 2392 } |
| 2393 |
| 2394 void test_divide_knownDouble_unknownInt() { |
| 2395 _assertDivide(_doubleValue(null), _doubleValue(6.0), _intValue(null)); |
| 2396 } |
| 2397 |
| 2398 void test_divide_knownInt_knownInt() { |
| 2399 _assertDivide(_doubleValue(3.0), _intValue(6), _intValue(2)); |
| 2400 } |
| 2401 |
| 2402 void test_divide_knownInt_knownString() { |
| 2403 _assertDivide(null, _intValue(6), _stringValue("2")); |
| 2404 } |
| 2405 |
| 2406 void test_divide_knownInt_unknownDouble() { |
| 2407 _assertDivide(_doubleValue(null), _intValue(6), _doubleValue(null)); |
| 2408 } |
| 2409 |
| 2410 void test_divide_knownInt_unknownInt() { |
| 2411 _assertDivide(_doubleValue(null), _intValue(6), _intValue(null)); |
| 2412 } |
| 2413 |
| 2414 void test_divide_knownString_knownInt() { |
| 2415 _assertDivide(null, _stringValue("6"), _intValue(2)); |
| 2416 } |
| 2417 |
| 2418 void test_divide_unknownDouble_knownDouble() { |
| 2419 _assertDivide(_doubleValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 2420 } |
| 2421 |
| 2422 void test_divide_unknownDouble_knownInt() { |
| 2423 _assertDivide(_doubleValue(null), _doubleValue(null), _intValue(2)); |
| 2424 } |
| 2425 |
| 2426 void test_divide_unknownInt_knownDouble() { |
| 2427 _assertDivide(_doubleValue(null), _intValue(null), _doubleValue(2.0)); |
| 2428 } |
| 2429 |
| 2430 void test_divide_unknownInt_knownInt() { |
| 2431 _assertDivide(_doubleValue(null), _intValue(null), _intValue(2)); |
| 2432 } |
| 2433 |
| 2434 void test_equalEqual_bool_false() { |
| 2435 _assertEqualEqual(_boolValue(false), _boolValue(false), _boolValue(true)); |
| 2436 } |
| 2437 |
| 2438 void test_equalEqual_bool_true() { |
| 2439 _assertEqualEqual(_boolValue(true), _boolValue(true), _boolValue(true)); |
| 2440 } |
| 2441 |
| 2442 void test_equalEqual_bool_unknown() { |
| 2443 _assertEqualEqual(_boolValue(null), _boolValue(null), _boolValue(false)); |
| 2444 } |
| 2445 |
| 2446 void test_equalEqual_double_false() { |
| 2447 _assertEqualEqual(_boolValue(false), _doubleValue(2.0), _doubleValue(4.0)); |
| 2448 } |
| 2449 |
| 2450 void test_equalEqual_double_true() { |
| 2451 _assertEqualEqual(_boolValue(true), _doubleValue(2.0), _doubleValue(2.0)); |
| 2452 } |
| 2453 |
| 2454 void test_equalEqual_double_unknown() { |
| 2455 _assertEqualEqual(_boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 2456 } |
| 2457 |
| 2458 void test_equalEqual_int_false() { |
| 2459 _assertEqualEqual(_boolValue(false), _intValue(-5), _intValue(5)); |
| 2460 } |
| 2461 |
| 2462 void test_equalEqual_int_true() { |
| 2463 _assertEqualEqual(_boolValue(true), _intValue(5), _intValue(5)); |
| 2464 } |
| 2465 |
| 2466 void test_equalEqual_int_unknown() { |
| 2467 _assertEqualEqual(_boolValue(null), _intValue(null), _intValue(3)); |
| 2468 } |
| 2469 |
| 2470 void test_equalEqual_list_empty() { |
| 2471 _assertEqualEqual(null, _listValue(), _listValue()); |
| 2472 } |
| 2473 |
| 2474 void test_equalEqual_list_false() { |
| 2475 _assertEqualEqual(null, _listValue(), _listValue()); |
| 2476 } |
| 2477 |
| 2478 void test_equalEqual_map_empty() { |
| 2479 _assertEqualEqual(null, _mapValue(), _mapValue()); |
| 2480 } |
| 2481 |
| 2482 void test_equalEqual_map_false() { |
| 2483 _assertEqualEqual(null, _mapValue(), _mapValue()); |
| 2484 } |
| 2485 |
| 2486 void test_equalEqual_null() { |
| 2487 _assertEqualEqual(_boolValue(true), _nullValue(), _nullValue()); |
| 2488 } |
| 2489 |
| 2490 void test_equalEqual_string_false() { |
| 2491 _assertEqualEqual( |
| 2492 _boolValue(false), _stringValue("abc"), _stringValue("def")); |
| 2493 } |
| 2494 |
| 2495 void test_equalEqual_string_true() { |
| 2496 _assertEqualEqual( |
| 2497 _boolValue(true), _stringValue("abc"), _stringValue("abc")); |
| 2498 } |
| 2499 |
| 2500 void test_equalEqual_string_unknown() { |
| 2501 _assertEqualEqual( |
| 2502 _boolValue(null), _stringValue(null), _stringValue("def")); |
| 2503 } |
| 2504 |
| 2505 void test_equals_list_false_differentSizes() { |
| 2506 expect( |
| 2507 _listValue([_boolValue(true)]) == |
| 2508 _listValue([_boolValue(true), _boolValue(false)]), |
| 2509 isFalse); |
| 2510 } |
| 2511 |
| 2512 void test_equals_list_false_sameSize() { |
| 2513 expect(_listValue([_boolValue(true)]) == _listValue([_boolValue(false)]), |
| 2514 isFalse); |
| 2515 } |
| 2516 |
| 2517 void test_equals_list_true_empty() { |
| 2518 expect(_listValue(), _listValue()); |
| 2519 } |
| 2520 |
| 2521 void test_equals_list_true_nonEmpty() { |
| 2522 expect(_listValue([_boolValue(true)]), _listValue([_boolValue(true)])); |
| 2523 } |
| 2524 |
| 2525 void test_equals_map_true_empty() { |
| 2526 expect(_mapValue(), _mapValue()); |
| 2527 } |
| 2528 |
| 2529 void test_equals_symbol_false() { |
| 2530 expect(_symbolValue("a") == _symbolValue("b"), isFalse); |
| 2531 } |
| 2532 |
| 2533 void test_equals_symbol_true() { |
| 2534 expect(_symbolValue("a"), _symbolValue("a")); |
| 2535 } |
| 2536 |
| 2537 void test_getValue_bool_false() { |
| 2538 expect(_boolValue(false).toBoolValue(), false); |
| 2539 } |
| 2540 |
| 2541 void test_getValue_bool_true() { |
| 2542 expect(_boolValue(true).toBoolValue(), true); |
| 2543 } |
| 2544 |
| 2545 void test_getValue_bool_unknown() { |
| 2546 expect(_boolValue(null).toBoolValue(), isNull); |
| 2547 } |
| 2548 |
| 2549 void test_getValue_double_known() { |
| 2550 double value = 2.3; |
| 2551 expect(_doubleValue(value).toDoubleValue(), value); |
| 2552 } |
| 2553 |
| 2554 void test_getValue_double_unknown() { |
| 2555 expect(_doubleValue(null).toDoubleValue(), isNull); |
| 2556 } |
| 2557 |
| 2558 void test_getValue_int_known() { |
| 2559 int value = 23; |
| 2560 expect(_intValue(value).toIntValue(), value); |
| 2561 } |
| 2562 |
| 2563 void test_getValue_int_unknown() { |
| 2564 expect(_intValue(null).toIntValue(), isNull); |
| 2565 } |
| 2566 |
| 2567 void test_getValue_list_empty() { |
| 2568 Object result = _listValue().toListValue(); |
| 2569 _assertInstanceOfObjectArray(result); |
| 2570 List<Object> array = result as List<Object>; |
| 2571 expect(array, hasLength(0)); |
| 2572 } |
| 2573 |
| 2574 void test_getValue_list_valid() { |
| 2575 Object result = _listValue([_intValue(23)]).toListValue(); |
| 2576 _assertInstanceOfObjectArray(result); |
| 2577 List<Object> array = result as List<Object>; |
| 2578 expect(array, hasLength(1)); |
| 2579 } |
| 2580 |
| 2581 void test_getValue_map_empty() { |
| 2582 Object result = _mapValue().toMapValue(); |
| 2583 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result); |
| 2584 Map map = result as Map; |
| 2585 expect(map, hasLength(0)); |
| 2586 } |
| 2587 |
| 2588 void test_getValue_map_valid() { |
| 2589 Object result = |
| 2590 _mapValue([_stringValue("key"), _stringValue("value")]).toMapValue(); |
| 2591 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result); |
| 2592 Map map = result as Map; |
| 2593 expect(map, hasLength(1)); |
| 2594 } |
| 2595 |
| 2596 void test_getValue_null() { |
| 2597 expect(_nullValue().isNull, isTrue); |
| 2598 } |
| 2599 |
| 2600 void test_getValue_string_known() { |
| 2601 String value = "twenty-three"; |
| 2602 expect(_stringValue(value).toStringValue(), value); |
| 2603 } |
| 2604 |
| 2605 void test_getValue_string_unknown() { |
| 2606 expect(_stringValue(null).toStringValue(), isNull); |
| 2607 } |
| 2608 |
| 2609 void test_greaterThan_knownDouble_knownDouble_false() { |
| 2610 _assertGreaterThan(_boolValue(false), _doubleValue(1.0), _doubleValue(2.0)); |
| 2611 } |
| 2612 |
| 2613 void test_greaterThan_knownDouble_knownDouble_true() { |
| 2614 _assertGreaterThan(_boolValue(true), _doubleValue(2.0), _doubleValue(1.0)); |
| 2615 } |
| 2616 |
| 2617 void test_greaterThan_knownDouble_knownInt_false() { |
| 2618 _assertGreaterThan(_boolValue(false), _doubleValue(1.0), _intValue(2)); |
| 2619 } |
| 2620 |
| 2621 void test_greaterThan_knownDouble_knownInt_true() { |
| 2622 _assertGreaterThan(_boolValue(true), _doubleValue(2.0), _intValue(1)); |
| 2623 } |
| 2624 |
| 2625 void test_greaterThan_knownDouble_unknownDouble() { |
| 2626 _assertGreaterThan(_boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 2627 } |
| 2628 |
| 2629 void test_greaterThan_knownDouble_unknownInt() { |
| 2630 _assertGreaterThan(_boolValue(null), _doubleValue(1.0), _intValue(null)); |
| 2631 } |
| 2632 |
| 2633 void test_greaterThan_knownInt_knownInt_false() { |
| 2634 _assertGreaterThan(_boolValue(false), _intValue(1), _intValue(2)); |
| 2635 } |
| 2636 |
| 2637 void test_greaterThan_knownInt_knownInt_true() { |
| 2638 _assertGreaterThan(_boolValue(true), _intValue(2), _intValue(1)); |
| 2639 } |
| 2640 |
| 2641 void test_greaterThan_knownInt_knownString() { |
| 2642 _assertGreaterThan(null, _intValue(1), _stringValue("2")); |
| 2643 } |
| 2644 |
| 2645 void test_greaterThan_knownInt_unknownDouble() { |
| 2646 _assertGreaterThan(_boolValue(null), _intValue(1), _doubleValue(null)); |
| 2647 } |
| 2648 |
| 2649 void test_greaterThan_knownInt_unknownInt() { |
| 2650 _assertGreaterThan(_boolValue(null), _intValue(1), _intValue(null)); |
| 2651 } |
| 2652 |
| 2653 void test_greaterThan_knownString_knownInt() { |
| 2654 _assertGreaterThan(null, _stringValue("1"), _intValue(2)); |
| 2655 } |
| 2656 |
| 2657 void test_greaterThan_unknownDouble_knownDouble() { |
| 2658 _assertGreaterThan(_boolValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 2659 } |
| 2660 |
| 2661 void test_greaterThan_unknownDouble_knownInt() { |
| 2662 _assertGreaterThan(_boolValue(null), _doubleValue(null), _intValue(2)); |
| 2663 } |
| 2664 |
| 2665 void test_greaterThan_unknownInt_knownDouble() { |
| 2666 _assertGreaterThan(_boolValue(null), _intValue(null), _doubleValue(2.0)); |
| 2667 } |
| 2668 |
| 2669 void test_greaterThan_unknownInt_knownInt() { |
| 2670 _assertGreaterThan(_boolValue(null), _intValue(null), _intValue(2)); |
| 2671 } |
| 2672 |
| 2673 void test_greaterThanOrEqual_knownDouble_knownDouble_false() { |
| 2674 _assertGreaterThanOrEqual( |
| 2675 _boolValue(false), _doubleValue(1.0), _doubleValue(2.0)); |
| 2676 } |
| 2677 |
| 2678 void test_greaterThanOrEqual_knownDouble_knownDouble_true() { |
| 2679 _assertGreaterThanOrEqual( |
| 2680 _boolValue(true), _doubleValue(2.0), _doubleValue(1.0)); |
| 2681 } |
| 2682 |
| 2683 void test_greaterThanOrEqual_knownDouble_knownInt_false() { |
| 2684 _assertGreaterThanOrEqual( |
| 2685 _boolValue(false), _doubleValue(1.0), _intValue(2)); |
| 2686 } |
| 2687 |
| 2688 void test_greaterThanOrEqual_knownDouble_knownInt_true() { |
| 2689 _assertGreaterThanOrEqual( |
| 2690 _boolValue(true), _doubleValue(2.0), _intValue(1)); |
| 2691 } |
| 2692 |
| 2693 void test_greaterThanOrEqual_knownDouble_unknownDouble() { |
| 2694 _assertGreaterThanOrEqual( |
| 2695 _boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 2696 } |
| 2697 |
| 2698 void test_greaterThanOrEqual_knownDouble_unknownInt() { |
| 2699 _assertGreaterThanOrEqual( |
| 2700 _boolValue(null), _doubleValue(1.0), _intValue(null)); |
| 2701 } |
| 2702 |
| 2703 void test_greaterThanOrEqual_knownInt_knownInt_false() { |
| 2704 _assertGreaterThanOrEqual(_boolValue(false), _intValue(1), _intValue(2)); |
| 2705 } |
| 2706 |
| 2707 void test_greaterThanOrEqual_knownInt_knownInt_true() { |
| 2708 _assertGreaterThanOrEqual(_boolValue(true), _intValue(2), _intValue(2)); |
| 2709 } |
| 2710 |
| 2711 void test_greaterThanOrEqual_knownInt_knownString() { |
| 2712 _assertGreaterThanOrEqual(null, _intValue(1), _stringValue("2")); |
| 2713 } |
| 2714 |
| 2715 void test_greaterThanOrEqual_knownInt_unknownDouble() { |
| 2716 _assertGreaterThanOrEqual( |
| 2717 _boolValue(null), _intValue(1), _doubleValue(null)); |
| 2718 } |
| 2719 |
| 2720 void test_greaterThanOrEqual_knownInt_unknownInt() { |
| 2721 _assertGreaterThanOrEqual(_boolValue(null), _intValue(1), _intValue(null)); |
| 2722 } |
| 2723 |
| 2724 void test_greaterThanOrEqual_knownString_knownInt() { |
| 2725 _assertGreaterThanOrEqual(null, _stringValue("1"), _intValue(2)); |
| 2726 } |
| 2727 |
| 2728 void test_greaterThanOrEqual_unknownDouble_knownDouble() { |
| 2729 _assertGreaterThanOrEqual( |
| 2730 _boolValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 2731 } |
| 2732 |
| 2733 void test_greaterThanOrEqual_unknownDouble_knownInt() { |
| 2734 _assertGreaterThanOrEqual( |
| 2735 _boolValue(null), _doubleValue(null), _intValue(2)); |
| 2736 } |
| 2737 |
| 2738 void test_greaterThanOrEqual_unknownInt_knownDouble() { |
| 2739 _assertGreaterThanOrEqual( |
| 2740 _boolValue(null), _intValue(null), _doubleValue(2.0)); |
| 2741 } |
| 2742 |
| 2743 void test_greaterThanOrEqual_unknownInt_knownInt() { |
| 2744 _assertGreaterThanOrEqual(_boolValue(null), _intValue(null), _intValue(2)); |
| 2745 } |
| 2746 |
| 2747 void test_hasKnownValue_bool_false() { |
| 2748 expect(_boolValue(false).hasKnownValue, isTrue); |
| 2749 } |
| 2750 |
| 2751 void test_hasKnownValue_bool_true() { |
| 2752 expect(_boolValue(true).hasKnownValue, isTrue); |
| 2753 } |
| 2754 |
| 2755 void test_hasKnownValue_bool_unknown() { |
| 2756 expect(_boolValue(null).hasKnownValue, isFalse); |
| 2757 } |
| 2758 |
| 2759 void test_hasKnownValue_double_known() { |
| 2760 expect(_doubleValue(2.3).hasKnownValue, isTrue); |
| 2761 } |
| 2762 |
| 2763 void test_hasKnownValue_double_unknown() { |
| 2764 expect(_doubleValue(null).hasKnownValue, isFalse); |
| 2765 } |
| 2766 |
| 2767 void test_hasKnownValue_dynamic() { |
| 2768 expect(_dynamicValue().hasKnownValue, isTrue); |
| 2769 } |
| 2770 |
| 2771 void test_hasKnownValue_int_known() { |
| 2772 expect(_intValue(23).hasKnownValue, isTrue); |
| 2773 } |
| 2774 |
| 2775 void test_hasKnownValue_int_unknown() { |
| 2776 expect(_intValue(null).hasKnownValue, isFalse); |
| 2777 } |
| 2778 |
| 2779 void test_hasKnownValue_list_empty() { |
| 2780 expect(_listValue().hasKnownValue, isTrue); |
| 2781 } |
| 2782 |
| 2783 void test_hasKnownValue_list_invalidElement() { |
| 2784 expect(_listValue([_dynamicValue]).hasKnownValue, isTrue); |
| 2785 } |
| 2786 |
| 2787 void test_hasKnownValue_list_valid() { |
| 2788 expect(_listValue([_intValue(23)]).hasKnownValue, isTrue); |
| 2789 } |
| 2790 |
| 2791 void test_hasKnownValue_map_empty() { |
| 2792 expect(_mapValue().hasKnownValue, isTrue); |
| 2793 } |
| 2794 |
| 2795 void test_hasKnownValue_map_invalidKey() { |
| 2796 expect(_mapValue([_dynamicValue(), _stringValue("value")]).hasKnownValue, |
| 2797 isTrue); |
| 2798 } |
| 2799 |
| 2800 void test_hasKnownValue_map_invalidValue() { |
| 2801 expect(_mapValue([_stringValue("key"), _dynamicValue()]).hasKnownValue, |
| 2802 isTrue); |
| 2803 } |
| 2804 |
| 2805 void test_hasKnownValue_map_valid() { |
| 2806 expect( |
| 2807 _mapValue([_stringValue("key"), _stringValue("value")]).hasKnownValue, |
| 2808 isTrue); |
| 2809 } |
| 2810 |
| 2811 void test_hasKnownValue_null() { |
| 2812 expect(_nullValue().hasKnownValue, isTrue); |
| 2813 } |
| 2814 |
| 2815 void test_hasKnownValue_num() { |
| 2816 expect(_numValue().hasKnownValue, isFalse); |
| 2817 } |
| 2818 |
| 2819 void test_hasKnownValue_string_known() { |
| 2820 expect(_stringValue("twenty-three").hasKnownValue, isTrue); |
| 2821 } |
| 2822 |
| 2823 void test_hasKnownValue_string_unknown() { |
| 2824 expect(_stringValue(null).hasKnownValue, isFalse); |
| 2825 } |
| 2826 |
| 2827 void test_identical_bool_false() { |
| 2828 _assertIdentical(_boolValue(false), _boolValue(false), _boolValue(true)); |
| 2829 } |
| 2830 |
| 2831 void test_identical_bool_true() { |
| 2832 _assertIdentical(_boolValue(true), _boolValue(true), _boolValue(true)); |
| 2833 } |
| 2834 |
| 2835 void test_identical_bool_unknown() { |
| 2836 _assertIdentical(_boolValue(null), _boolValue(null), _boolValue(false)); |
| 2837 } |
| 2838 |
| 2839 void test_identical_double_false() { |
| 2840 _assertIdentical(_boolValue(false), _doubleValue(2.0), _doubleValue(4.0)); |
| 2841 } |
| 2842 |
| 2843 void test_identical_double_true() { |
| 2844 _assertIdentical(_boolValue(true), _doubleValue(2.0), _doubleValue(2.0)); |
| 2845 } |
| 2846 |
| 2847 void test_identical_double_unknown() { |
| 2848 _assertIdentical(_boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 2849 } |
| 2850 |
| 2851 void test_identical_int_false() { |
| 2852 _assertIdentical(_boolValue(false), _intValue(-5), _intValue(5)); |
| 2853 } |
| 2854 |
| 2855 void test_identical_int_true() { |
| 2856 _assertIdentical(_boolValue(true), _intValue(5), _intValue(5)); |
| 2857 } |
| 2858 |
| 2859 void test_identical_int_unknown() { |
| 2860 _assertIdentical(_boolValue(null), _intValue(null), _intValue(3)); |
| 2861 } |
| 2862 |
| 2863 void test_identical_list_empty() { |
| 2864 _assertIdentical(_boolValue(true), _listValue(), _listValue()); |
| 2865 } |
| 2866 |
| 2867 void test_identical_list_false() { |
| 2868 _assertIdentical( |
| 2869 _boolValue(false), _listValue(), _listValue([_intValue(3)])); |
| 2870 } |
| 2871 |
| 2872 void test_identical_map_empty() { |
| 2873 _assertIdentical(_boolValue(true), _mapValue(), _mapValue()); |
| 2874 } |
| 2875 |
| 2876 void test_identical_map_false() { |
| 2877 _assertIdentical(_boolValue(false), _mapValue(), |
| 2878 _mapValue([_intValue(1), _intValue(2)])); |
| 2879 } |
| 2880 |
| 2881 void test_identical_null() { |
| 2882 _assertIdentical(_boolValue(true), _nullValue(), _nullValue()); |
| 2883 } |
| 2884 |
| 2885 void test_identical_string_false() { |
| 2886 _assertIdentical( |
| 2887 _boolValue(false), _stringValue("abc"), _stringValue("def")); |
| 2888 } |
| 2889 |
| 2890 void test_identical_string_true() { |
| 2891 _assertIdentical( |
| 2892 _boolValue(true), _stringValue("abc"), _stringValue("abc")); |
| 2893 } |
| 2894 |
| 2895 void test_identical_string_unknown() { |
| 2896 _assertIdentical(_boolValue(null), _stringValue(null), _stringValue("def")); |
| 2897 } |
| 2898 |
| 2899 void test_integerDivide_knownDouble_knownDouble() { |
| 2900 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _doubleValue(2.0)); |
| 2901 } |
| 2902 |
| 2903 void test_integerDivide_knownDouble_knownInt() { |
| 2904 _assertIntegerDivide(_intValue(3), _doubleValue(6.0), _intValue(2)); |
| 2905 } |
| 2906 |
| 2907 void test_integerDivide_knownDouble_unknownDouble() { |
| 2908 _assertIntegerDivide( |
| 2909 _intValue(null), _doubleValue(6.0), _doubleValue(null)); |
| 2910 } |
| 2911 |
| 2912 void test_integerDivide_knownDouble_unknownInt() { |
| 2913 _assertIntegerDivide(_intValue(null), _doubleValue(6.0), _intValue(null)); |
| 2914 } |
| 2915 |
| 2916 void test_integerDivide_knownInt_knownInt() { |
| 2917 _assertIntegerDivide(_intValue(3), _intValue(6), _intValue(2)); |
| 2918 } |
| 2919 |
| 2920 void test_integerDivide_knownInt_knownString() { |
| 2921 _assertIntegerDivide(null, _intValue(6), _stringValue("2")); |
| 2922 } |
| 2923 |
| 2924 void test_integerDivide_knownInt_unknownDouble() { |
| 2925 _assertIntegerDivide(_intValue(null), _intValue(6), _doubleValue(null)); |
| 2926 } |
| 2927 |
| 2928 void test_integerDivide_knownInt_unknownInt() { |
| 2929 _assertIntegerDivide(_intValue(null), _intValue(6), _intValue(null)); |
| 2930 } |
| 2931 |
| 2932 void test_integerDivide_knownString_knownInt() { |
| 2933 _assertIntegerDivide(null, _stringValue("6"), _intValue(2)); |
| 2934 } |
| 2935 |
| 2936 void test_integerDivide_unknownDouble_knownDouble() { |
| 2937 _assertIntegerDivide( |
| 2938 _intValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 2939 } |
| 2940 |
| 2941 void test_integerDivide_unknownDouble_knownInt() { |
| 2942 _assertIntegerDivide(_intValue(null), _doubleValue(null), _intValue(2)); |
| 2943 } |
| 2944 |
| 2945 void test_integerDivide_unknownInt_knownDouble() { |
| 2946 _assertIntegerDivide(_intValue(null), _intValue(null), _doubleValue(2.0)); |
| 2947 } |
| 2948 |
| 2949 void test_integerDivide_unknownInt_knownInt() { |
| 2950 _assertIntegerDivide(_intValue(null), _intValue(null), _intValue(2)); |
| 2951 } |
| 2952 |
| 2953 void test_isBoolNumStringOrNull_bool_false() { |
| 2954 expect(_boolValue(false).isBoolNumStringOrNull, isTrue); |
| 2955 } |
| 2956 |
| 2957 void test_isBoolNumStringOrNull_bool_true() { |
| 2958 expect(_boolValue(true).isBoolNumStringOrNull, isTrue); |
| 2959 } |
| 2960 |
| 2961 void test_isBoolNumStringOrNull_bool_unknown() { |
| 2962 expect(_boolValue(null).isBoolNumStringOrNull, isTrue); |
| 2963 } |
| 2964 |
| 2965 void test_isBoolNumStringOrNull_double_known() { |
| 2966 expect(_doubleValue(2.3).isBoolNumStringOrNull, isTrue); |
| 2967 } |
| 2968 |
| 2969 void test_isBoolNumStringOrNull_double_unknown() { |
| 2970 expect(_doubleValue(null).isBoolNumStringOrNull, isTrue); |
| 2971 } |
| 2972 |
| 2973 void test_isBoolNumStringOrNull_dynamic() { |
| 2974 expect(_dynamicValue().isBoolNumStringOrNull, isTrue); |
| 2975 } |
| 2976 |
| 2977 void test_isBoolNumStringOrNull_int_known() { |
| 2978 expect(_intValue(23).isBoolNumStringOrNull, isTrue); |
| 2979 } |
| 2980 |
| 2981 void test_isBoolNumStringOrNull_int_unknown() { |
| 2982 expect(_intValue(null).isBoolNumStringOrNull, isTrue); |
| 2983 } |
| 2984 |
| 2985 void test_isBoolNumStringOrNull_list() { |
| 2986 expect(_listValue().isBoolNumStringOrNull, isFalse); |
| 2987 } |
| 2988 |
| 2989 void test_isBoolNumStringOrNull_null() { |
| 2990 expect(_nullValue().isBoolNumStringOrNull, isTrue); |
| 2991 } |
| 2992 |
| 2993 void test_isBoolNumStringOrNull_num() { |
| 2994 expect(_numValue().isBoolNumStringOrNull, isTrue); |
| 2995 } |
| 2996 |
| 2997 void test_isBoolNumStringOrNull_string_known() { |
| 2998 expect(_stringValue("twenty-three").isBoolNumStringOrNull, isTrue); |
| 2999 } |
| 3000 |
| 3001 void test_isBoolNumStringOrNull_string_unknown() { |
| 3002 expect(_stringValue(null).isBoolNumStringOrNull, isTrue); |
| 3003 } |
| 3004 |
| 3005 void test_lessThan_knownDouble_knownDouble_false() { |
| 3006 _assertLessThan(_boolValue(false), _doubleValue(2.0), _doubleValue(1.0)); |
| 3007 } |
| 3008 |
| 3009 void test_lessThan_knownDouble_knownDouble_true() { |
| 3010 _assertLessThan(_boolValue(true), _doubleValue(1.0), _doubleValue(2.0)); |
| 3011 } |
| 3012 |
| 3013 void test_lessThan_knownDouble_knownInt_false() { |
| 3014 _assertLessThan(_boolValue(false), _doubleValue(2.0), _intValue(1)); |
| 3015 } |
| 3016 |
| 3017 void test_lessThan_knownDouble_knownInt_true() { |
| 3018 _assertLessThan(_boolValue(true), _doubleValue(1.0), _intValue(2)); |
| 3019 } |
| 3020 |
| 3021 void test_lessThan_knownDouble_unknownDouble() { |
| 3022 _assertLessThan(_boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 3023 } |
| 3024 |
| 3025 void test_lessThan_knownDouble_unknownInt() { |
| 3026 _assertLessThan(_boolValue(null), _doubleValue(1.0), _intValue(null)); |
| 3027 } |
| 3028 |
| 3029 void test_lessThan_knownInt_knownInt_false() { |
| 3030 _assertLessThan(_boolValue(false), _intValue(2), _intValue(1)); |
| 3031 } |
| 3032 |
| 3033 void test_lessThan_knownInt_knownInt_true() { |
| 3034 _assertLessThan(_boolValue(true), _intValue(1), _intValue(2)); |
| 3035 } |
| 3036 |
| 3037 void test_lessThan_knownInt_knownString() { |
| 3038 _assertLessThan(null, _intValue(1), _stringValue("2")); |
| 3039 } |
| 3040 |
| 3041 void test_lessThan_knownInt_unknownDouble() { |
| 3042 _assertLessThan(_boolValue(null), _intValue(1), _doubleValue(null)); |
| 3043 } |
| 3044 |
| 3045 void test_lessThan_knownInt_unknownInt() { |
| 3046 _assertLessThan(_boolValue(null), _intValue(1), _intValue(null)); |
| 3047 } |
| 3048 |
| 3049 void test_lessThan_knownString_knownInt() { |
| 3050 _assertLessThan(null, _stringValue("1"), _intValue(2)); |
| 3051 } |
| 3052 |
| 3053 void test_lessThan_unknownDouble_knownDouble() { |
| 3054 _assertLessThan(_boolValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 3055 } |
| 3056 |
| 3057 void test_lessThan_unknownDouble_knownInt() { |
| 3058 _assertLessThan(_boolValue(null), _doubleValue(null), _intValue(2)); |
| 3059 } |
| 3060 |
| 3061 void test_lessThan_unknownInt_knownDouble() { |
| 3062 _assertLessThan(_boolValue(null), _intValue(null), _doubleValue(2.0)); |
| 3063 } |
| 3064 |
| 3065 void test_lessThan_unknownInt_knownInt() { |
| 3066 _assertLessThan(_boolValue(null), _intValue(null), _intValue(2)); |
| 3067 } |
| 3068 |
| 3069 void test_lessThanOrEqual_knownDouble_knownDouble_false() { |
| 3070 _assertLessThanOrEqual( |
| 3071 _boolValue(false), _doubleValue(2.0), _doubleValue(1.0)); |
| 3072 } |
| 3073 |
| 3074 void test_lessThanOrEqual_knownDouble_knownDouble_true() { |
| 3075 _assertLessThanOrEqual( |
| 3076 _boolValue(true), _doubleValue(1.0), _doubleValue(2.0)); |
| 3077 } |
| 3078 |
| 3079 void test_lessThanOrEqual_knownDouble_knownInt_false() { |
| 3080 _assertLessThanOrEqual(_boolValue(false), _doubleValue(2.0), _intValue(1)); |
| 3081 } |
| 3082 |
| 3083 void test_lessThanOrEqual_knownDouble_knownInt_true() { |
| 3084 _assertLessThanOrEqual(_boolValue(true), _doubleValue(1.0), _intValue(2)); |
| 3085 } |
| 3086 |
| 3087 void test_lessThanOrEqual_knownDouble_unknownDouble() { |
| 3088 _assertLessThanOrEqual( |
| 3089 _boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 3090 } |
| 3091 |
| 3092 void test_lessThanOrEqual_knownDouble_unknownInt() { |
| 3093 _assertLessThanOrEqual( |
| 3094 _boolValue(null), _doubleValue(1.0), _intValue(null)); |
| 3095 } |
| 3096 |
| 3097 void test_lessThanOrEqual_knownInt_knownInt_false() { |
| 3098 _assertLessThanOrEqual(_boolValue(false), _intValue(2), _intValue(1)); |
| 3099 } |
| 3100 |
| 3101 void test_lessThanOrEqual_knownInt_knownInt_true() { |
| 3102 _assertLessThanOrEqual(_boolValue(true), _intValue(1), _intValue(2)); |
| 3103 } |
| 3104 |
| 3105 void test_lessThanOrEqual_knownInt_knownString() { |
| 3106 _assertLessThanOrEqual(null, _intValue(1), _stringValue("2")); |
| 3107 } |
| 3108 |
| 3109 void test_lessThanOrEqual_knownInt_unknownDouble() { |
| 3110 _assertLessThanOrEqual(_boolValue(null), _intValue(1), _doubleValue(null)); |
| 3111 } |
| 3112 |
| 3113 void test_lessThanOrEqual_knownInt_unknownInt() { |
| 3114 _assertLessThanOrEqual(_boolValue(null), _intValue(1), _intValue(null)); |
| 3115 } |
| 3116 |
| 3117 void test_lessThanOrEqual_knownString_knownInt() { |
| 3118 _assertLessThanOrEqual(null, _stringValue("1"), _intValue(2)); |
| 3119 } |
| 3120 |
| 3121 void test_lessThanOrEqual_unknownDouble_knownDouble() { |
| 3122 _assertLessThanOrEqual( |
| 3123 _boolValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 3124 } |
| 3125 |
| 3126 void test_lessThanOrEqual_unknownDouble_knownInt() { |
| 3127 _assertLessThanOrEqual(_boolValue(null), _doubleValue(null), _intValue(2)); |
| 3128 } |
| 3129 |
| 3130 void test_lessThanOrEqual_unknownInt_knownDouble() { |
| 3131 _assertLessThanOrEqual( |
| 3132 _boolValue(null), _intValue(null), _doubleValue(2.0)); |
| 3133 } |
| 3134 |
| 3135 void test_lessThanOrEqual_unknownInt_knownInt() { |
| 3136 _assertLessThanOrEqual(_boolValue(null), _intValue(null), _intValue(2)); |
| 3137 } |
| 3138 |
| 3139 void test_logicalAnd_false_false() { |
| 3140 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(false)); |
| 3141 } |
| 3142 |
| 3143 void test_logicalAnd_false_null() { |
| 3144 try { |
| 3145 _assertLogicalAnd(_boolValue(false), _boolValue(false), _nullValue()); |
| 3146 fail("Expected EvaluationException"); |
| 3147 } on EvaluationException {} |
| 3148 } |
| 3149 |
| 3150 void test_logicalAnd_false_string() { |
| 3151 try { |
| 3152 _assertLogicalAnd( |
| 3153 _boolValue(false), _boolValue(false), _stringValue("false")); |
| 3154 fail("Expected EvaluationException"); |
| 3155 } on EvaluationException {} |
| 3156 } |
| 3157 |
| 3158 void test_logicalAnd_false_true() { |
| 3159 _assertLogicalAnd(_boolValue(false), _boolValue(false), _boolValue(true)); |
| 3160 } |
| 3161 |
| 3162 void test_logicalAnd_null_false() { |
| 3163 try { |
| 3164 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(false)); |
| 3165 fail("Expected EvaluationException"); |
| 3166 } on EvaluationException {} |
| 3167 } |
| 3168 |
| 3169 void test_logicalAnd_null_true() { |
| 3170 try { |
| 3171 _assertLogicalAnd(_boolValue(false), _nullValue(), _boolValue(true)); |
| 3172 fail("Expected EvaluationException"); |
| 3173 } on EvaluationException {} |
| 3174 } |
| 3175 |
| 3176 void test_logicalAnd_string_false() { |
| 3177 try { |
| 3178 _assertLogicalAnd( |
| 3179 _boolValue(false), _stringValue("true"), _boolValue(false)); |
| 3180 fail("Expected EvaluationException"); |
| 3181 } on EvaluationException {} |
| 3182 } |
| 3183 |
| 3184 void test_logicalAnd_string_true() { |
| 3185 try { |
| 3186 _assertLogicalAnd( |
| 3187 _boolValue(false), _stringValue("false"), _boolValue(true)); |
| 3188 fail("Expected EvaluationException"); |
| 3189 } on EvaluationException {} |
| 3190 } |
| 3191 |
| 3192 void test_logicalAnd_true_false() { |
| 3193 _assertLogicalAnd(_boolValue(false), _boolValue(true), _boolValue(false)); |
| 3194 } |
| 3195 |
| 3196 void test_logicalAnd_true_null() { |
| 3197 _assertLogicalAnd(null, _boolValue(true), _nullValue()); |
| 3198 } |
| 3199 |
| 3200 void test_logicalAnd_true_string() { |
| 3201 try { |
| 3202 _assertLogicalAnd( |
| 3203 _boolValue(false), _boolValue(true), _stringValue("true")); |
| 3204 fail("Expected EvaluationException"); |
| 3205 } on EvaluationException {} |
| 3206 } |
| 3207 |
| 3208 void test_logicalAnd_true_true() { |
| 3209 _assertLogicalAnd(_boolValue(true), _boolValue(true), _boolValue(true)); |
| 3210 } |
| 3211 |
| 3212 void test_logicalNot_false() { |
| 3213 _assertLogicalNot(_boolValue(true), _boolValue(false)); |
| 3214 } |
| 3215 |
| 3216 void test_logicalNot_null() { |
| 3217 _assertLogicalNot(null, _nullValue()); |
| 3218 } |
| 3219 |
| 3220 void test_logicalNot_string() { |
| 3221 try { |
| 3222 _assertLogicalNot(_boolValue(true), _stringValue(null)); |
| 3223 fail("Expected EvaluationException"); |
| 3224 } on EvaluationException {} |
| 3225 } |
| 3226 |
| 3227 void test_logicalNot_true() { |
| 3228 _assertLogicalNot(_boolValue(false), _boolValue(true)); |
| 3229 } |
| 3230 |
| 3231 void test_logicalNot_unknown() { |
| 3232 _assertLogicalNot(_boolValue(null), _boolValue(null)); |
| 3233 } |
| 3234 |
| 3235 void test_logicalOr_false_false() { |
| 3236 _assertLogicalOr(_boolValue(false), _boolValue(false), _boolValue(false)); |
| 3237 } |
| 3238 |
| 3239 void test_logicalOr_false_null() { |
| 3240 _assertLogicalOr(null, _boolValue(false), _nullValue()); |
| 3241 } |
| 3242 |
| 3243 void test_logicalOr_false_string() { |
| 3244 try { |
| 3245 _assertLogicalOr( |
| 3246 _boolValue(false), _boolValue(false), _stringValue("false")); |
| 3247 fail("Expected EvaluationException"); |
| 3248 } on EvaluationException {} |
| 3249 } |
| 3250 |
| 3251 void test_logicalOr_false_true() { |
| 3252 _assertLogicalOr(_boolValue(true), _boolValue(false), _boolValue(true)); |
| 3253 } |
| 3254 |
| 3255 void test_logicalOr_null_false() { |
| 3256 try { |
| 3257 _assertLogicalOr(_boolValue(false), _nullValue(), _boolValue(false)); |
| 3258 fail("Expected EvaluationException"); |
| 3259 } on EvaluationException {} |
| 3260 } |
| 3261 |
| 3262 void test_logicalOr_null_true() { |
| 3263 try { |
| 3264 _assertLogicalOr(_boolValue(true), _nullValue(), _boolValue(true)); |
| 3265 fail("Expected EvaluationException"); |
| 3266 } on EvaluationException {} |
| 3267 } |
| 3268 |
| 3269 void test_logicalOr_string_false() { |
| 3270 try { |
| 3271 _assertLogicalOr( |
| 3272 _boolValue(false), _stringValue("true"), _boolValue(false)); |
| 3273 fail("Expected EvaluationException"); |
| 3274 } on EvaluationException {} |
| 3275 } |
| 3276 |
| 3277 void test_logicalOr_string_true() { |
| 3278 try { |
| 3279 _assertLogicalOr( |
| 3280 _boolValue(true), _stringValue("false"), _boolValue(true)); |
| 3281 fail("Expected EvaluationException"); |
| 3282 } on EvaluationException {} |
| 3283 } |
| 3284 |
| 3285 void test_logicalOr_true_false() { |
| 3286 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(false)); |
| 3287 } |
| 3288 |
| 3289 void test_logicalOr_true_null() { |
| 3290 try { |
| 3291 _assertLogicalOr(_boolValue(true), _boolValue(true), _nullValue()); |
| 3292 fail("Expected EvaluationException"); |
| 3293 } on EvaluationException {} |
| 3294 } |
| 3295 |
| 3296 void test_logicalOr_true_string() { |
| 3297 try { |
| 3298 _assertLogicalOr( |
| 3299 _boolValue(true), _boolValue(true), _stringValue("true")); |
| 3300 fail("Expected EvaluationException"); |
| 3301 } on EvaluationException {} |
| 3302 } |
| 3303 |
| 3304 void test_logicalOr_true_true() { |
| 3305 _assertLogicalOr(_boolValue(true), _boolValue(true), _boolValue(true)); |
| 3306 } |
| 3307 |
| 3308 void test_minus_knownDouble_knownDouble() { |
| 3309 _assertMinus(_doubleValue(1.0), _doubleValue(4.0), _doubleValue(3.0)); |
| 3310 } |
| 3311 |
| 3312 void test_minus_knownDouble_knownInt() { |
| 3313 _assertMinus(_doubleValue(1.0), _doubleValue(4.0), _intValue(3)); |
| 3314 } |
| 3315 |
| 3316 void test_minus_knownDouble_unknownDouble() { |
| 3317 _assertMinus(_doubleValue(null), _doubleValue(4.0), _doubleValue(null)); |
| 3318 } |
| 3319 |
| 3320 void test_minus_knownDouble_unknownInt() { |
| 3321 _assertMinus(_doubleValue(null), _doubleValue(4.0), _intValue(null)); |
| 3322 } |
| 3323 |
| 3324 void test_minus_knownInt_knownInt() { |
| 3325 _assertMinus(_intValue(1), _intValue(4), _intValue(3)); |
| 3326 } |
| 3327 |
| 3328 void test_minus_knownInt_knownString() { |
| 3329 _assertMinus(null, _intValue(4), _stringValue("3")); |
| 3330 } |
| 3331 |
| 3332 void test_minus_knownInt_unknownDouble() { |
| 3333 _assertMinus(_doubleValue(null), _intValue(4), _doubleValue(null)); |
| 3334 } |
| 3335 |
| 3336 void test_minus_knownInt_unknownInt() { |
| 3337 _assertMinus(_intValue(null), _intValue(4), _intValue(null)); |
| 3338 } |
| 3339 |
| 3340 void test_minus_knownString_knownInt() { |
| 3341 _assertMinus(null, _stringValue("4"), _intValue(3)); |
| 3342 } |
| 3343 |
| 3344 void test_minus_unknownDouble_knownDouble() { |
| 3345 _assertMinus(_doubleValue(null), _doubleValue(null), _doubleValue(3.0)); |
| 3346 } |
| 3347 |
| 3348 void test_minus_unknownDouble_knownInt() { |
| 3349 _assertMinus(_doubleValue(null), _doubleValue(null), _intValue(3)); |
| 3350 } |
| 3351 |
| 3352 void test_minus_unknownInt_knownDouble() { |
| 3353 _assertMinus(_doubleValue(null), _intValue(null), _doubleValue(3.0)); |
| 3354 } |
| 3355 |
| 3356 void test_minus_unknownInt_knownInt() { |
| 3357 _assertMinus(_intValue(null), _intValue(null), _intValue(3)); |
| 3358 } |
| 3359 |
| 3360 void test_negated_double_known() { |
| 3361 _assertNegated(_doubleValue(2.0), _doubleValue(-2.0)); |
| 3362 } |
| 3363 |
| 3364 void test_negated_double_unknown() { |
| 3365 _assertNegated(_doubleValue(null), _doubleValue(null)); |
| 3366 } |
| 3367 |
| 3368 void test_negated_int_known() { |
| 3369 _assertNegated(_intValue(-3), _intValue(3)); |
| 3370 } |
| 3371 |
| 3372 void test_negated_int_unknown() { |
| 3373 _assertNegated(_intValue(null), _intValue(null)); |
| 3374 } |
| 3375 |
| 3376 void test_negated_string() { |
| 3377 _assertNegated(null, _stringValue(null)); |
| 3378 } |
| 3379 |
| 3380 void test_notEqual_bool_false() { |
| 3381 _assertNotEqual(_boolValue(false), _boolValue(true), _boolValue(true)); |
| 3382 } |
| 3383 |
| 3384 void test_notEqual_bool_true() { |
| 3385 _assertNotEqual(_boolValue(true), _boolValue(false), _boolValue(true)); |
| 3386 } |
| 3387 |
| 3388 void test_notEqual_bool_unknown() { |
| 3389 _assertNotEqual(_boolValue(null), _boolValue(null), _boolValue(false)); |
| 3390 } |
| 3391 |
| 3392 void test_notEqual_double_false() { |
| 3393 _assertNotEqual(_boolValue(false), _doubleValue(2.0), _doubleValue(2.0)); |
| 3394 } |
| 3395 |
| 3396 void test_notEqual_double_true() { |
| 3397 _assertNotEqual(_boolValue(true), _doubleValue(2.0), _doubleValue(4.0)); |
| 3398 } |
| 3399 |
| 3400 void test_notEqual_double_unknown() { |
| 3401 _assertNotEqual(_boolValue(null), _doubleValue(1.0), _doubleValue(null)); |
| 3402 } |
| 3403 |
| 3404 void test_notEqual_int_false() { |
| 3405 _assertNotEqual(_boolValue(false), _intValue(5), _intValue(5)); |
| 3406 } |
| 3407 |
| 3408 void test_notEqual_int_true() { |
| 3409 _assertNotEqual(_boolValue(true), _intValue(-5), _intValue(5)); |
| 3410 } |
| 3411 |
| 3412 void test_notEqual_int_unknown() { |
| 3413 _assertNotEqual(_boolValue(null), _intValue(null), _intValue(3)); |
| 3414 } |
| 3415 |
| 3416 void test_notEqual_null() { |
| 3417 _assertNotEqual(_boolValue(false), _nullValue(), _nullValue()); |
| 3418 } |
| 3419 |
| 3420 void test_notEqual_string_false() { |
| 3421 _assertNotEqual( |
| 3422 _boolValue(false), _stringValue("abc"), _stringValue("abc")); |
| 3423 } |
| 3424 |
| 3425 void test_notEqual_string_true() { |
| 3426 _assertNotEqual(_boolValue(true), _stringValue("abc"), _stringValue("def")); |
| 3427 } |
| 3428 |
| 3429 void test_notEqual_string_unknown() { |
| 3430 _assertNotEqual(_boolValue(null), _stringValue(null), _stringValue("def")); |
| 3431 } |
| 3432 |
| 3433 void test_performToString_bool_false() { |
| 3434 _assertPerformToString(_stringValue("false"), _boolValue(false)); |
| 3435 } |
| 3436 |
| 3437 void test_performToString_bool_true() { |
| 3438 _assertPerformToString(_stringValue("true"), _boolValue(true)); |
| 3439 } |
| 3440 |
| 3441 void test_performToString_bool_unknown() { |
| 3442 _assertPerformToString(_stringValue(null), _boolValue(null)); |
| 3443 } |
| 3444 |
| 3445 void test_performToString_double_known() { |
| 3446 _assertPerformToString(_stringValue("2.0"), _doubleValue(2.0)); |
| 3447 } |
| 3448 |
| 3449 void test_performToString_double_unknown() { |
| 3450 _assertPerformToString(_stringValue(null), _doubleValue(null)); |
| 3451 } |
| 3452 |
| 3453 void test_performToString_int_known() { |
| 3454 _assertPerformToString(_stringValue("5"), _intValue(5)); |
| 3455 } |
| 3456 |
| 3457 void test_performToString_int_unknown() { |
| 3458 _assertPerformToString(_stringValue(null), _intValue(null)); |
| 3459 } |
| 3460 |
| 3461 void test_performToString_null() { |
| 3462 _assertPerformToString(_stringValue("null"), _nullValue()); |
| 3463 } |
| 3464 |
| 3465 void test_performToString_string_known() { |
| 3466 _assertPerformToString(_stringValue("abc"), _stringValue("abc")); |
| 3467 } |
| 3468 |
| 3469 void test_performToString_string_unknown() { |
| 3470 _assertPerformToString(_stringValue(null), _stringValue(null)); |
| 3471 } |
| 3472 |
| 3473 void test_remainder_knownDouble_knownDouble() { |
| 3474 _assertRemainder(_doubleValue(1.0), _doubleValue(7.0), _doubleValue(2.0)); |
| 3475 } |
| 3476 |
| 3477 void test_remainder_knownDouble_knownInt() { |
| 3478 _assertRemainder(_doubleValue(1.0), _doubleValue(7.0), _intValue(2)); |
| 3479 } |
| 3480 |
| 3481 void test_remainder_knownDouble_unknownDouble() { |
| 3482 _assertRemainder(_doubleValue(null), _doubleValue(7.0), _doubleValue(null)); |
| 3483 } |
| 3484 |
| 3485 void test_remainder_knownDouble_unknownInt() { |
| 3486 _assertRemainder(_doubleValue(null), _doubleValue(6.0), _intValue(null)); |
| 3487 } |
| 3488 |
| 3489 void test_remainder_knownInt_knownInt() { |
| 3490 _assertRemainder(_intValue(1), _intValue(7), _intValue(2)); |
| 3491 } |
| 3492 |
| 3493 void test_remainder_knownInt_knownString() { |
| 3494 _assertRemainder(null, _intValue(7), _stringValue("2")); |
| 3495 } |
| 3496 |
| 3497 void test_remainder_knownInt_unknownDouble() { |
| 3498 _assertRemainder(_doubleValue(null), _intValue(7), _doubleValue(null)); |
| 3499 } |
| 3500 |
| 3501 void test_remainder_knownInt_unknownInt() { |
| 3502 _assertRemainder(_intValue(null), _intValue(7), _intValue(null)); |
| 3503 } |
| 3504 |
| 3505 void test_remainder_knownString_knownInt() { |
| 3506 _assertRemainder(null, _stringValue("7"), _intValue(2)); |
| 3507 } |
| 3508 |
| 3509 void test_remainder_unknownDouble_knownDouble() { |
| 3510 _assertRemainder(_doubleValue(null), _doubleValue(null), _doubleValue(2.0)); |
| 3511 } |
| 3512 |
| 3513 void test_remainder_unknownDouble_knownInt() { |
| 3514 _assertRemainder(_doubleValue(null), _doubleValue(null), _intValue(2)); |
| 3515 } |
| 3516 |
| 3517 void test_remainder_unknownInt_knownDouble() { |
| 3518 _assertRemainder(_doubleValue(null), _intValue(null), _doubleValue(2.0)); |
| 3519 } |
| 3520 |
| 3521 void test_remainder_unknownInt_knownInt() { |
| 3522 _assertRemainder(_intValue(null), _intValue(null), _intValue(2)); |
| 3523 } |
| 3524 |
| 3525 void test_shiftLeft_knownInt_knownInt() { |
| 3526 _assertShiftLeft(_intValue(48), _intValue(6), _intValue(3)); |
| 3527 } |
| 3528 |
| 3529 void test_shiftLeft_knownInt_knownString() { |
| 3530 _assertShiftLeft(null, _intValue(6), _stringValue(null)); |
| 3531 } |
| 3532 |
| 3533 void test_shiftLeft_knownInt_tooLarge() { |
| 3534 _assertShiftLeft( |
| 3535 _intValue(null), |
| 3536 _intValue(6), |
| 3537 new DartObjectImpl( |
| 3538 _typeProvider.intType, new IntState(LONG_MAX_VALUE))); |
| 3539 } |
| 3540 |
| 3541 void test_shiftLeft_knownInt_unknownInt() { |
| 3542 _assertShiftLeft(_intValue(null), _intValue(6), _intValue(null)); |
| 3543 } |
| 3544 |
| 3545 void test_shiftLeft_knownString_knownInt() { |
| 3546 _assertShiftLeft(null, _stringValue(null), _intValue(3)); |
| 3547 } |
| 3548 |
| 3549 void test_shiftLeft_unknownInt_knownInt() { |
| 3550 _assertShiftLeft(_intValue(null), _intValue(null), _intValue(3)); |
| 3551 } |
| 3552 |
| 3553 void test_shiftLeft_unknownInt_unknownInt() { |
| 3554 _assertShiftLeft(_intValue(null), _intValue(null), _intValue(null)); |
| 3555 } |
| 3556 |
| 3557 void test_shiftRight_knownInt_knownInt() { |
| 3558 _assertShiftRight(_intValue(6), _intValue(48), _intValue(3)); |
| 3559 } |
| 3560 |
| 3561 void test_shiftRight_knownInt_knownString() { |
| 3562 _assertShiftRight(null, _intValue(48), _stringValue(null)); |
| 3563 } |
| 3564 |
| 3565 void test_shiftRight_knownInt_tooLarge() { |
| 3566 _assertShiftRight( |
| 3567 _intValue(null), |
| 3568 _intValue(48), |
| 3569 new DartObjectImpl( |
| 3570 _typeProvider.intType, new IntState(LONG_MAX_VALUE))); |
| 3571 } |
| 3572 |
| 3573 void test_shiftRight_knownInt_unknownInt() { |
| 3574 _assertShiftRight(_intValue(null), _intValue(48), _intValue(null)); |
| 3575 } |
| 3576 |
| 3577 void test_shiftRight_knownString_knownInt() { |
| 3578 _assertShiftRight(null, _stringValue(null), _intValue(3)); |
| 3579 } |
| 3580 |
| 3581 void test_shiftRight_unknownInt_knownInt() { |
| 3582 _assertShiftRight(_intValue(null), _intValue(null), _intValue(3)); |
| 3583 } |
| 3584 |
| 3585 void test_shiftRight_unknownInt_unknownInt() { |
| 3586 _assertShiftRight(_intValue(null), _intValue(null), _intValue(null)); |
| 3587 } |
| 3588 |
| 3589 void test_stringLength_int() { |
| 3590 try { |
| 3591 _assertStringLength(_intValue(null), _intValue(0)); |
| 3592 fail("Expected EvaluationException"); |
| 3593 } on EvaluationException {} |
| 3594 } |
| 3595 |
| 3596 void test_stringLength_knownString() { |
| 3597 _assertStringLength(_intValue(3), _stringValue("abc")); |
| 3598 } |
| 3599 |
| 3600 void test_stringLength_unknownString() { |
| 3601 _assertStringLength(_intValue(null), _stringValue(null)); |
| 3602 } |
| 3603 |
| 3604 void test_times_knownDouble_knownDouble() { |
| 3605 _assertTimes(_doubleValue(6.0), _doubleValue(2.0), _doubleValue(3.0)); |
| 3606 } |
| 3607 |
| 3608 void test_times_knownDouble_knownInt() { |
| 3609 _assertTimes(_doubleValue(6.0), _doubleValue(2.0), _intValue(3)); |
| 3610 } |
| 3611 |
| 3612 void test_times_knownDouble_unknownDouble() { |
| 3613 _assertTimes(_doubleValue(null), _doubleValue(2.0), _doubleValue(null)); |
| 3614 } |
| 3615 |
| 3616 void test_times_knownDouble_unknownInt() { |
| 3617 _assertTimes(_doubleValue(null), _doubleValue(2.0), _intValue(null)); |
| 3618 } |
| 3619 |
| 3620 void test_times_knownInt_knownInt() { |
| 3621 _assertTimes(_intValue(6), _intValue(2), _intValue(3)); |
| 3622 } |
| 3623 |
| 3624 void test_times_knownInt_knownString() { |
| 3625 _assertTimes(null, _intValue(2), _stringValue("3")); |
| 3626 } |
| 3627 |
| 3628 void test_times_knownInt_unknownDouble() { |
| 3629 _assertTimes(_doubleValue(null), _intValue(2), _doubleValue(null)); |
| 3630 } |
| 3631 |
| 3632 void test_times_knownInt_unknownInt() { |
| 3633 _assertTimes(_intValue(null), _intValue(2), _intValue(null)); |
| 3634 } |
| 3635 |
| 3636 void test_times_knownString_knownInt() { |
| 3637 _assertTimes(null, _stringValue("2"), _intValue(3)); |
| 3638 } |
| 3639 |
| 3640 void test_times_unknownDouble_knownDouble() { |
| 3641 _assertTimes(_doubleValue(null), _doubleValue(null), _doubleValue(3.0)); |
| 3642 } |
| 3643 |
| 3644 void test_times_unknownDouble_knownInt() { |
| 3645 _assertTimes(_doubleValue(null), _doubleValue(null), _intValue(3)); |
| 3646 } |
| 3647 |
| 3648 void test_times_unknownInt_knownDouble() { |
| 3649 _assertTimes(_doubleValue(null), _intValue(null), _doubleValue(3.0)); |
| 3650 } |
| 3651 |
| 3652 void test_times_unknownInt_knownInt() { |
| 3653 _assertTimes(_intValue(null), _intValue(null), _intValue(3)); |
| 3654 } |
| 3655 |
| 3656 /** |
| 3657 * Assert that the result of adding the left and right operands is the expecte
d value, or that the |
| 3658 * operation throws an exception if the expected value is `null`. |
| 3659 * |
| 3660 * @param expected the expected result of the operation |
| 3661 * @param leftOperand the left operand to the operation |
| 3662 * @param rightOperand the left operand to the operation |
| 3663 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3664 */ |
| 3665 void _assertAdd(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3666 DartObjectImpl rightOperand) { |
| 3667 if (expected == null) { |
| 3668 try { |
| 3669 leftOperand.add(_typeProvider, rightOperand); |
| 3670 fail("Expected an EvaluationException"); |
| 3671 } on EvaluationException {} |
| 3672 } else { |
| 3673 DartObjectImpl result = leftOperand.add(_typeProvider, rightOperand); |
| 3674 expect(result, isNotNull); |
| 3675 expect(result, expected); |
| 3676 } |
| 3677 } |
| 3678 |
| 3679 /** |
| 3680 * Assert that the result of bit-anding the left and right operands is the exp
ected value, or that |
| 3681 * the operation throws an exception if the expected value is `null`. |
| 3682 * |
| 3683 * @param expected the expected result of the operation |
| 3684 * @param leftOperand the left operand to the operation |
| 3685 * @param rightOperand the left operand to the operation |
| 3686 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3687 */ |
| 3688 void _assertBitAnd(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3689 DartObjectImpl rightOperand) { |
| 3690 if (expected == null) { |
| 3691 try { |
| 3692 leftOperand.bitAnd(_typeProvider, rightOperand); |
| 3693 fail("Expected an EvaluationException"); |
| 3694 } on EvaluationException {} |
| 3695 } else { |
| 3696 DartObjectImpl result = leftOperand.bitAnd(_typeProvider, rightOperand); |
| 3697 expect(result, isNotNull); |
| 3698 expect(result, expected); |
| 3699 } |
| 3700 } |
| 3701 |
| 3702 /** |
| 3703 * Assert that the bit-not of the operand is the expected value, or that the o
peration throws an |
| 3704 * exception if the expected value is `null`. |
| 3705 * |
| 3706 * @param expected the expected result of the operation |
| 3707 * @param operand the operand to the operation |
| 3708 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3709 */ |
| 3710 void _assertBitNot(DartObjectImpl expected, DartObjectImpl operand) { |
| 3711 if (expected == null) { |
| 3712 try { |
| 3713 operand.bitNot(_typeProvider); |
| 3714 fail("Expected an EvaluationException"); |
| 3715 } on EvaluationException {} |
| 3716 } else { |
| 3717 DartObjectImpl result = operand.bitNot(_typeProvider); |
| 3718 expect(result, isNotNull); |
| 3719 expect(result, expected); |
| 3720 } |
| 3721 } |
| 3722 |
| 3723 /** |
| 3724 * Assert that the result of bit-oring the left and right operands is the expe
cted value, or that |
| 3725 * the operation throws an exception if the expected value is `null`. |
| 3726 * |
| 3727 * @param expected the expected result of the operation |
| 3728 * @param leftOperand the left operand to the operation |
| 3729 * @param rightOperand the left operand to the operation |
| 3730 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3731 */ |
| 3732 void _assertBitOr(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3733 DartObjectImpl rightOperand) { |
| 3734 if (expected == null) { |
| 3735 try { |
| 3736 leftOperand.bitOr(_typeProvider, rightOperand); |
| 3737 fail("Expected an EvaluationException"); |
| 3738 } on EvaluationException {} |
| 3739 } else { |
| 3740 DartObjectImpl result = leftOperand.bitOr(_typeProvider, rightOperand); |
| 3741 expect(result, isNotNull); |
| 3742 expect(result, expected); |
| 3743 } |
| 3744 } |
| 3745 |
| 3746 /** |
| 3747 * Assert that the result of bit-xoring the left and right operands is the exp
ected value, or that |
| 3748 * the operation throws an exception if the expected value is `null`. |
| 3749 * |
| 3750 * @param expected the expected result of the operation |
| 3751 * @param leftOperand the left operand to the operation |
| 3752 * @param rightOperand the left operand to the operation |
| 3753 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3754 */ |
| 3755 void _assertBitXor(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3756 DartObjectImpl rightOperand) { |
| 3757 if (expected == null) { |
| 3758 try { |
| 3759 leftOperand.bitXor(_typeProvider, rightOperand); |
| 3760 fail("Expected an EvaluationException"); |
| 3761 } on EvaluationException {} |
| 3762 } else { |
| 3763 DartObjectImpl result = leftOperand.bitXor(_typeProvider, rightOperand); |
| 3764 expect(result, isNotNull); |
| 3765 expect(result, expected); |
| 3766 } |
| 3767 } |
| 3768 |
| 3769 /** |
| 3770 * Assert that the result of concatenating the left and right operands is the
expected value, or |
| 3771 * that the operation throws an exception if the expected value is `null`. |
| 3772 * |
| 3773 * @param expected the expected result of the operation |
| 3774 * @param leftOperand the left operand to the operation |
| 3775 * @param rightOperand the left operand to the operation |
| 3776 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3777 */ |
| 3778 void _assertConcatenate(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3779 DartObjectImpl rightOperand) { |
| 3780 if (expected == null) { |
| 3781 try { |
| 3782 leftOperand.concatenate(_typeProvider, rightOperand); |
| 3783 fail("Expected an EvaluationException"); |
| 3784 } on EvaluationException {} |
| 3785 } else { |
| 3786 DartObjectImpl result = |
| 3787 leftOperand.concatenate(_typeProvider, rightOperand); |
| 3788 expect(result, isNotNull); |
| 3789 expect(result, expected); |
| 3790 } |
| 3791 } |
| 3792 |
| 3793 /** |
| 3794 * Assert that the result of dividing the left and right operands is the expec
ted value, or that |
| 3795 * the operation throws an exception if the expected value is `null`. |
| 3796 * |
| 3797 * @param expected the expected result of the operation |
| 3798 * @param leftOperand the left operand to the operation |
| 3799 * @param rightOperand the left operand to the operation |
| 3800 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3801 */ |
| 3802 void _assertDivide(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3803 DartObjectImpl rightOperand) { |
| 3804 if (expected == null) { |
| 3805 try { |
| 3806 leftOperand.divide(_typeProvider, rightOperand); |
| 3807 fail("Expected an EvaluationException"); |
| 3808 } on EvaluationException {} |
| 3809 } else { |
| 3810 DartObjectImpl result = leftOperand.divide(_typeProvider, rightOperand); |
| 3811 expect(result, isNotNull); |
| 3812 expect(result, expected); |
| 3813 } |
| 3814 } |
| 3815 |
| 3816 /** |
| 3817 * Assert that the result of comparing the left and right operands for equalit
y is the expected |
| 3818 * value, or that the operation throws an exception if the expected value is `
null`. |
| 3819 * |
| 3820 * @param expected the expected result of the operation |
| 3821 * @param leftOperand the left operand to the operation |
| 3822 * @param rightOperand the left operand to the operation |
| 3823 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3824 */ |
| 3825 void _assertEqualEqual(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3826 DartObjectImpl rightOperand) { |
| 3827 if (expected == null) { |
| 3828 try { |
| 3829 leftOperand.equalEqual(_typeProvider, rightOperand); |
| 3830 fail("Expected an EvaluationException"); |
| 3831 } on EvaluationException {} |
| 3832 } else { |
| 3833 DartObjectImpl result = |
| 3834 leftOperand.equalEqual(_typeProvider, rightOperand); |
| 3835 expect(result, isNotNull); |
| 3836 expect(result, expected); |
| 3837 } |
| 3838 } |
| 3839 |
| 3840 /** |
| 3841 * Assert that the result of comparing the left and right operands is the expe
cted value, or that |
| 3842 * the operation throws an exception if the expected value is `null`. |
| 3843 * |
| 3844 * @param expected the expected result of the operation |
| 3845 * @param leftOperand the left operand to the operation |
| 3846 * @param rightOperand the left operand to the operation |
| 3847 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3848 */ |
| 3849 void _assertGreaterThan(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3850 DartObjectImpl rightOperand) { |
| 3851 if (expected == null) { |
| 3852 try { |
| 3853 leftOperand.greaterThan(_typeProvider, rightOperand); |
| 3854 fail("Expected an EvaluationException"); |
| 3855 } on EvaluationException {} |
| 3856 } else { |
| 3857 DartObjectImpl result = |
| 3858 leftOperand.greaterThan(_typeProvider, rightOperand); |
| 3859 expect(result, isNotNull); |
| 3860 expect(result, expected); |
| 3861 } |
| 3862 } |
| 3863 |
| 3864 /** |
| 3865 * Assert that the result of comparing the left and right operands is the expe
cted value, or that |
| 3866 * the operation throws an exception if the expected value is `null`. |
| 3867 * |
| 3868 * @param expected the expected result of the operation |
| 3869 * @param leftOperand the left operand to the operation |
| 3870 * @param rightOperand the left operand to the operation |
| 3871 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3872 */ |
| 3873 void _assertGreaterThanOrEqual(DartObjectImpl expected, |
| 3874 DartObjectImpl leftOperand, DartObjectImpl rightOperand) { |
| 3875 if (expected == null) { |
| 3876 try { |
| 3877 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand); |
| 3878 fail("Expected an EvaluationException"); |
| 3879 } on EvaluationException {} |
| 3880 } else { |
| 3881 DartObjectImpl result = |
| 3882 leftOperand.greaterThanOrEqual(_typeProvider, rightOperand); |
| 3883 expect(result, isNotNull); |
| 3884 expect(result, expected); |
| 3885 } |
| 3886 } |
| 3887 |
| 3888 /** |
| 3889 * Assert that the result of comparing the left and right operands using |
| 3890 * identical() is the expected value. |
| 3891 * |
| 3892 * @param expected the expected result of the operation |
| 3893 * @param leftOperand the left operand to the operation |
| 3894 * @param rightOperand the left operand to the operation |
| 3895 */ |
| 3896 void _assertIdentical(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3897 DartObjectImpl rightOperand) { |
| 3898 DartObjectImpl result = |
| 3899 leftOperand.isIdentical(_typeProvider, rightOperand); |
| 3900 expect(result, isNotNull); |
| 3901 expect(result, expected); |
| 3902 } |
| 3903 |
| 3904 void _assertInstanceOfObjectArray(Object result) { |
| 3905 // TODO(scheglov) implement |
| 3906 } |
| 3907 |
| 3908 /** |
| 3909 * Assert that the result of dividing the left and right operands as integers
is the expected |
| 3910 * value, or that the operation throws an exception if the expected value is `
null`. |
| 3911 * |
| 3912 * @param expected the expected result of the operation |
| 3913 * @param leftOperand the left operand to the operation |
| 3914 * @param rightOperand the left operand to the operation |
| 3915 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3916 */ |
| 3917 void _assertIntegerDivide(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3918 DartObjectImpl rightOperand) { |
| 3919 if (expected == null) { |
| 3920 try { |
| 3921 leftOperand.integerDivide(_typeProvider, rightOperand); |
| 3922 fail("Expected an EvaluationException"); |
| 3923 } on EvaluationException {} |
| 3924 } else { |
| 3925 DartObjectImpl result = |
| 3926 leftOperand.integerDivide(_typeProvider, rightOperand); |
| 3927 expect(result, isNotNull); |
| 3928 expect(result, expected); |
| 3929 } |
| 3930 } |
| 3931 |
| 3932 /** |
| 3933 * Assert that the result of comparing the left and right operands is the expe
cted value, or that |
| 3934 * the operation throws an exception if the expected value is `null`. |
| 3935 * |
| 3936 * @param expected the expected result of the operation |
| 3937 * @param leftOperand the left operand to the operation |
| 3938 * @param rightOperand the left operand to the operation |
| 3939 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3940 */ |
| 3941 void _assertLessThan(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3942 DartObjectImpl rightOperand) { |
| 3943 if (expected == null) { |
| 3944 try { |
| 3945 leftOperand.lessThan(_typeProvider, rightOperand); |
| 3946 fail("Expected an EvaluationException"); |
| 3947 } on EvaluationException {} |
| 3948 } else { |
| 3949 DartObjectImpl result = leftOperand.lessThan(_typeProvider, rightOperand); |
| 3950 expect(result, isNotNull); |
| 3951 expect(result, expected); |
| 3952 } |
| 3953 } |
| 3954 |
| 3955 /** |
| 3956 * Assert that the result of comparing the left and right operands is the expe
cted value, or that |
| 3957 * the operation throws an exception if the expected value is `null`. |
| 3958 * |
| 3959 * @param expected the expected result of the operation |
| 3960 * @param leftOperand the left operand to the operation |
| 3961 * @param rightOperand the left operand to the operation |
| 3962 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3963 */ |
| 3964 void _assertLessThanOrEqual(DartObjectImpl expected, |
| 3965 DartObjectImpl leftOperand, DartObjectImpl rightOperand) { |
| 3966 if (expected == null) { |
| 3967 try { |
| 3968 leftOperand.lessThanOrEqual(_typeProvider, rightOperand); |
| 3969 fail("Expected an EvaluationException"); |
| 3970 } on EvaluationException {} |
| 3971 } else { |
| 3972 DartObjectImpl result = |
| 3973 leftOperand.lessThanOrEqual(_typeProvider, rightOperand); |
| 3974 expect(result, isNotNull); |
| 3975 expect(result, expected); |
| 3976 } |
| 3977 } |
| 3978 |
| 3979 /** |
| 3980 * Assert that the result of logical-anding the left and right operands is the
expected value, or |
| 3981 * that the operation throws an exception if the expected value is `null`. |
| 3982 * |
| 3983 * @param expected the expected result of the operation |
| 3984 * @param leftOperand the left operand to the operation |
| 3985 * @param rightOperand the left operand to the operation |
| 3986 * @throws EvaluationException if the result is an exception when it should no
t be |
| 3987 */ |
| 3988 void _assertLogicalAnd(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 3989 DartObjectImpl rightOperand) { |
| 3990 if (expected == null) { |
| 3991 try { |
| 3992 leftOperand.logicalAnd(_typeProvider, rightOperand); |
| 3993 fail("Expected an EvaluationException"); |
| 3994 } on EvaluationException {} |
| 3995 } else { |
| 3996 DartObjectImpl result = |
| 3997 leftOperand.logicalAnd(_typeProvider, rightOperand); |
| 3998 expect(result, isNotNull); |
| 3999 expect(result, expected); |
| 4000 } |
| 4001 } |
| 4002 |
| 4003 /** |
| 4004 * Assert that the logical-not of the operand is the expected value, or that t
he operation throws |
| 4005 * an exception if the expected value is `null`. |
| 4006 * |
| 4007 * @param expected the expected result of the operation |
| 4008 * @param operand the operand to the operation |
| 4009 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4010 */ |
| 4011 void _assertLogicalNot(DartObjectImpl expected, DartObjectImpl operand) { |
| 4012 if (expected == null) { |
| 4013 try { |
| 4014 operand.logicalNot(_typeProvider); |
| 4015 fail("Expected an EvaluationException"); |
| 4016 } on EvaluationException {} |
| 4017 } else { |
| 4018 DartObjectImpl result = operand.logicalNot(_typeProvider); |
| 4019 expect(result, isNotNull); |
| 4020 expect(result, expected); |
| 4021 } |
| 4022 } |
| 4023 |
| 4024 /** |
| 4025 * Assert that the result of logical-oring the left and right operands is the
expected value, or |
| 4026 * that the operation throws an exception if the expected value is `null`. |
| 4027 * |
| 4028 * @param expected the expected result of the operation |
| 4029 * @param leftOperand the left operand to the operation |
| 4030 * @param rightOperand the left operand to the operation |
| 4031 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4032 */ |
| 4033 void _assertLogicalOr(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4034 DartObjectImpl rightOperand) { |
| 4035 if (expected == null) { |
| 4036 try { |
| 4037 leftOperand.logicalOr(_typeProvider, rightOperand); |
| 4038 fail("Expected an EvaluationException"); |
| 4039 } on EvaluationException {} |
| 4040 } else { |
| 4041 DartObjectImpl result = |
| 4042 leftOperand.logicalOr(_typeProvider, rightOperand); |
| 4043 expect(result, isNotNull); |
| 4044 expect(result, expected); |
| 4045 } |
| 4046 } |
| 4047 |
| 4048 /** |
| 4049 * Assert that the result of subtracting the left and right operands is the ex
pected value, or |
| 4050 * that the operation throws an exception if the expected value is `null`. |
| 4051 * |
| 4052 * @param expected the expected result of the operation |
| 4053 * @param leftOperand the left operand to the operation |
| 4054 * @param rightOperand the left operand to the operation |
| 4055 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4056 */ |
| 4057 void _assertMinus(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4058 DartObjectImpl rightOperand) { |
| 4059 if (expected == null) { |
| 4060 try { |
| 4061 leftOperand.minus(_typeProvider, rightOperand); |
| 4062 fail("Expected an EvaluationException"); |
| 4063 } on EvaluationException {} |
| 4064 } else { |
| 4065 DartObjectImpl result = leftOperand.minus(_typeProvider, rightOperand); |
| 4066 expect(result, isNotNull); |
| 4067 expect(result, expected); |
| 4068 } |
| 4069 } |
| 4070 |
| 4071 /** |
| 4072 * Assert that the negation of the operand is the expected value, or that the
operation throws an |
| 4073 * exception if the expected value is `null`. |
| 4074 * |
| 4075 * @param expected the expected result of the operation |
| 4076 * @param operand the operand to the operation |
| 4077 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4078 */ |
| 4079 void _assertNegated(DartObjectImpl expected, DartObjectImpl operand) { |
| 4080 if (expected == null) { |
| 4081 try { |
| 4082 operand.negated(_typeProvider); |
| 4083 fail("Expected an EvaluationException"); |
| 4084 } on EvaluationException {} |
| 4085 } else { |
| 4086 DartObjectImpl result = operand.negated(_typeProvider); |
| 4087 expect(result, isNotNull); |
| 4088 expect(result, expected); |
| 4089 } |
| 4090 } |
| 4091 |
| 4092 /** |
| 4093 * Assert that the result of comparing the left and right operands for inequal
ity is the expected |
| 4094 * value, or that the operation throws an exception if the expected value is `
null`. |
| 4095 * |
| 4096 * @param expected the expected result of the operation |
| 4097 * @param leftOperand the left operand to the operation |
| 4098 * @param rightOperand the left operand to the operation |
| 4099 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4100 */ |
| 4101 void _assertNotEqual(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4102 DartObjectImpl rightOperand) { |
| 4103 if (expected == null) { |
| 4104 try { |
| 4105 leftOperand.notEqual(_typeProvider, rightOperand); |
| 4106 fail("Expected an EvaluationException"); |
| 4107 } on EvaluationException {} |
| 4108 } else { |
| 4109 DartObjectImpl result = leftOperand.notEqual(_typeProvider, rightOperand); |
| 4110 expect(result, isNotNull); |
| 4111 expect(result, expected); |
| 4112 } |
| 4113 } |
| 4114 |
| 4115 /** |
| 4116 * Assert that converting the operand to a string is the expected value, or th
at the operation |
| 4117 * throws an exception if the expected value is `null`. |
| 4118 * |
| 4119 * @param expected the expected result of the operation |
| 4120 * @param operand the operand to the operation |
| 4121 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4122 */ |
| 4123 void _assertPerformToString(DartObjectImpl expected, DartObjectImpl operand) { |
| 4124 if (expected == null) { |
| 4125 try { |
| 4126 operand.performToString(_typeProvider); |
| 4127 fail("Expected an EvaluationException"); |
| 4128 } on EvaluationException {} |
| 4129 } else { |
| 4130 DartObjectImpl result = operand.performToString(_typeProvider); |
| 4131 expect(result, isNotNull); |
| 4132 expect(result, expected); |
| 4133 } |
| 4134 } |
| 4135 |
| 4136 /** |
| 4137 * Assert that the result of taking the remainder of the left and right operan
ds is the expected |
| 4138 * value, or that the operation throws an exception if the expected value is `
null`. |
| 4139 * |
| 4140 * @param expected the expected result of the operation |
| 4141 * @param leftOperand the left operand to the operation |
| 4142 * @param rightOperand the left operand to the operation |
| 4143 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4144 */ |
| 4145 void _assertRemainder(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4146 DartObjectImpl rightOperand) { |
| 4147 if (expected == null) { |
| 4148 try { |
| 4149 leftOperand.remainder(_typeProvider, rightOperand); |
| 4150 fail("Expected an EvaluationException"); |
| 4151 } on EvaluationException {} |
| 4152 } else { |
| 4153 DartObjectImpl result = |
| 4154 leftOperand.remainder(_typeProvider, rightOperand); |
| 4155 expect(result, isNotNull); |
| 4156 expect(result, expected); |
| 4157 } |
| 4158 } |
| 4159 |
| 4160 /** |
| 4161 * Assert that the result of multiplying the left and right operands is the ex
pected value, or |
| 4162 * that the operation throws an exception if the expected value is `null`. |
| 4163 * |
| 4164 * @param expected the expected result of the operation |
| 4165 * @param leftOperand the left operand to the operation |
| 4166 * @param rightOperand the left operand to the operation |
| 4167 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4168 */ |
| 4169 void _assertShiftLeft(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4170 DartObjectImpl rightOperand) { |
| 4171 if (expected == null) { |
| 4172 try { |
| 4173 leftOperand.shiftLeft(_typeProvider, rightOperand); |
| 4174 fail("Expected an EvaluationException"); |
| 4175 } on EvaluationException {} |
| 4176 } else { |
| 4177 DartObjectImpl result = |
| 4178 leftOperand.shiftLeft(_typeProvider, rightOperand); |
| 4179 expect(result, isNotNull); |
| 4180 expect(result, expected); |
| 4181 } |
| 4182 } |
| 4183 |
| 4184 /** |
| 4185 * Assert that the result of multiplying the left and right operands is the ex
pected value, or |
| 4186 * that the operation throws an exception if the expected value is `null`. |
| 4187 * |
| 4188 * @param expected the expected result of the operation |
| 4189 * @param leftOperand the left operand to the operation |
| 4190 * @param rightOperand the left operand to the operation |
| 4191 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4192 */ |
| 4193 void _assertShiftRight(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4194 DartObjectImpl rightOperand) { |
| 4195 if (expected == null) { |
| 4196 try { |
| 4197 leftOperand.shiftRight(_typeProvider, rightOperand); |
| 4198 fail("Expected an EvaluationException"); |
| 4199 } on EvaluationException {} |
| 4200 } else { |
| 4201 DartObjectImpl result = |
| 4202 leftOperand.shiftRight(_typeProvider, rightOperand); |
| 4203 expect(result, isNotNull); |
| 4204 expect(result, expected); |
| 4205 } |
| 4206 } |
| 4207 |
| 4208 /** |
| 4209 * Assert that the length of the operand is the expected value, or that the op
eration throws an |
| 4210 * exception if the expected value is `null`. |
| 4211 * |
| 4212 * @param expected the expected result of the operation |
| 4213 * @param operand the operand to the operation |
| 4214 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4215 */ |
| 4216 void _assertStringLength(DartObjectImpl expected, DartObjectImpl operand) { |
| 4217 if (expected == null) { |
| 4218 try { |
| 4219 operand.stringLength(_typeProvider); |
| 4220 fail("Expected an EvaluationException"); |
| 4221 } on EvaluationException {} |
| 4222 } else { |
| 4223 DartObjectImpl result = operand.stringLength(_typeProvider); |
| 4224 expect(result, isNotNull); |
| 4225 expect(result, expected); |
| 4226 } |
| 4227 } |
| 4228 |
| 4229 /** |
| 4230 * Assert that the result of multiplying the left and right operands is the ex
pected value, or |
| 4231 * that the operation throws an exception if the expected value is `null`. |
| 4232 * |
| 4233 * @param expected the expected result of the operation |
| 4234 * @param leftOperand the left operand to the operation |
| 4235 * @param rightOperand the left operand to the operation |
| 4236 * @throws EvaluationException if the result is an exception when it should no
t be |
| 4237 */ |
| 4238 void _assertTimes(DartObjectImpl expected, DartObjectImpl leftOperand, |
| 4239 DartObjectImpl rightOperand) { |
| 4240 if (expected == null) { |
| 4241 try { |
| 4242 leftOperand.times(_typeProvider, rightOperand); |
| 4243 fail("Expected an EvaluationException"); |
| 4244 } on EvaluationException {} |
| 4245 } else { |
| 4246 DartObjectImpl result = leftOperand.times(_typeProvider, rightOperand); |
| 4247 expect(result, isNotNull); |
| 4248 expect(result, expected); |
| 4249 } |
| 4250 } |
| 4251 |
| 4252 DartObjectImpl _boolValue(bool value) { |
| 4253 if (value == null) { |
| 4254 return new DartObjectImpl( |
| 4255 _typeProvider.boolType, BoolState.UNKNOWN_VALUE); |
| 4256 } else if (identical(value, false)) { |
| 4257 return new DartObjectImpl(_typeProvider.boolType, BoolState.FALSE_STATE); |
| 4258 } else if (identical(value, true)) { |
| 4259 return new DartObjectImpl(_typeProvider.boolType, BoolState.TRUE_STATE); |
| 4260 } |
| 4261 fail("Invalid boolean value used in test"); |
| 4262 return null; |
| 4263 } |
| 4264 |
| 4265 DartObjectImpl _doubleValue(double value) { |
| 4266 if (value == null) { |
| 4267 return new DartObjectImpl( |
| 4268 _typeProvider.doubleType, DoubleState.UNKNOWN_VALUE); |
| 4269 } else { |
| 4270 return new DartObjectImpl( |
| 4271 _typeProvider.doubleType, new DoubleState(value)); |
| 4272 } |
| 4273 } |
| 4274 |
| 4275 DartObjectImpl _dynamicValue() { |
| 4276 return new DartObjectImpl( |
| 4277 _typeProvider.nullType, DynamicState.DYNAMIC_STATE); |
| 4278 } |
| 4279 |
| 4280 DartObjectImpl _intValue(int value) { |
| 4281 if (value == null) { |
| 4282 return new DartObjectImpl(_typeProvider.intType, IntState.UNKNOWN_VALUE); |
| 4283 } else { |
| 4284 return new DartObjectImpl(_typeProvider.intType, new IntState(value)); |
| 4285 } |
| 4286 } |
| 4287 |
| 4288 DartObjectImpl _listValue( |
| 4289 [List<DartObjectImpl> elements = DartObjectImpl.EMPTY_LIST]) { |
| 4290 return new DartObjectImpl(_typeProvider.listType, new ListState(elements)); |
| 4291 } |
| 4292 |
| 4293 DartObjectImpl _mapValue( |
| 4294 [List<DartObjectImpl> keyElementPairs = DartObjectImpl.EMPTY_LIST]) { |
| 4295 Map<DartObjectImpl, DartObjectImpl> map = |
| 4296 new Map<DartObjectImpl, DartObjectImpl>(); |
| 4297 int count = keyElementPairs.length; |
| 4298 for (int i = 0; i < count;) { |
| 4299 map[keyElementPairs[i++]] = keyElementPairs[i++]; |
| 4300 } |
| 4301 return new DartObjectImpl(_typeProvider.mapType, new MapState(map)); |
| 4302 } |
| 4303 |
| 4304 DartObjectImpl _nullValue() { |
| 4305 return new DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE); |
| 4306 } |
| 4307 |
| 4308 DartObjectImpl _numValue() { |
| 4309 return new DartObjectImpl(_typeProvider.nullType, NumState.UNKNOWN_VALUE); |
| 4310 } |
| 4311 |
| 4312 DartObjectImpl _stringValue(String value) { |
| 4313 if (value == null) { |
| 4314 return new DartObjectImpl( |
| 4315 _typeProvider.stringType, StringState.UNKNOWN_VALUE); |
| 4316 } else { |
| 4317 return new DartObjectImpl( |
| 4318 _typeProvider.stringType, new StringState(value)); |
| 4319 } |
| 4320 } |
| 4321 |
| 4322 DartObjectImpl _symbolValue(String value) { |
| 4323 return new DartObjectImpl(_typeProvider.symbolType, new SymbolState(value)); |
| 4324 } |
| 4325 } |
| 4326 |
| 4327 @reflectiveTest |
| 4328 class DeclaredVariablesTest extends EngineTestCase { |
| 4329 void test_getBool_false() { |
| 4330 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4331 String variableName = "var"; |
| 4332 DeclaredVariables variables = new DeclaredVariables(); |
| 4333 variables.define(variableName, "false"); |
| 4334 DartObject object = variables.getBool(typeProvider, variableName); |
| 4335 expect(object, isNotNull); |
| 4336 expect(object.toBoolValue(), false); |
| 4337 } |
| 4338 |
| 4339 void test_getBool_invalid() { |
| 4340 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4341 String variableName = "var"; |
| 4342 DeclaredVariables variables = new DeclaredVariables(); |
| 4343 variables.define(variableName, "not true"); |
| 4344 _assertNullDartObject( |
| 4345 typeProvider, variables.getBool(typeProvider, variableName)); |
| 4346 } |
| 4347 |
| 4348 void test_getBool_true() { |
| 4349 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4350 String variableName = "var"; |
| 4351 DeclaredVariables variables = new DeclaredVariables(); |
| 4352 variables.define(variableName, "true"); |
| 4353 DartObject object = variables.getBool(typeProvider, variableName); |
| 4354 expect(object, isNotNull); |
| 4355 expect(object.toBoolValue(), true); |
| 4356 } |
| 4357 |
| 4358 void test_getBool_undefined() { |
| 4359 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4360 String variableName = "var"; |
| 4361 DeclaredVariables variables = new DeclaredVariables(); |
| 4362 _assertUnknownDartObject( |
| 4363 typeProvider.boolType, variables.getBool(typeProvider, variableName)); |
| 4364 } |
| 4365 |
| 4366 void test_getInt_invalid() { |
| 4367 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4368 String variableName = "var"; |
| 4369 DeclaredVariables variables = new DeclaredVariables(); |
| 4370 variables.define(variableName, "four score and seven years"); |
| 4371 _assertNullDartObject( |
| 4372 typeProvider, variables.getInt(typeProvider, variableName)); |
| 4373 } |
| 4374 |
| 4375 void test_getInt_undefined() { |
| 4376 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4377 String variableName = "var"; |
| 4378 DeclaredVariables variables = new DeclaredVariables(); |
| 4379 _assertUnknownDartObject( |
| 4380 typeProvider.intType, variables.getInt(typeProvider, variableName)); |
| 4381 } |
| 4382 |
| 4383 void test_getInt_valid() { |
| 4384 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4385 String variableName = "var"; |
| 4386 DeclaredVariables variables = new DeclaredVariables(); |
| 4387 variables.define(variableName, "23"); |
| 4388 DartObject object = variables.getInt(typeProvider, variableName); |
| 4389 expect(object, isNotNull); |
| 4390 expect(object.toIntValue(), 23); |
| 4391 } |
| 4392 |
| 4393 void test_getString_defined() { |
| 4394 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4395 String variableName = "var"; |
| 4396 String value = "value"; |
| 4397 DeclaredVariables variables = new DeclaredVariables(); |
| 4398 variables.define(variableName, value); |
| 4399 DartObject object = variables.getString(typeProvider, variableName); |
| 4400 expect(object, isNotNull); |
| 4401 expect(object.toStringValue(), value); |
| 4402 } |
| 4403 |
| 4404 void test_getString_undefined() { |
| 4405 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 4406 String variableName = "var"; |
| 4407 DeclaredVariables variables = new DeclaredVariables(); |
| 4408 _assertUnknownDartObject(typeProvider.stringType, |
| 4409 variables.getString(typeProvider, variableName)); |
| 4410 } |
| 4411 |
| 4412 void _assertNullDartObject(TestTypeProvider typeProvider, DartObject result) { |
| 4413 expect(result.type, typeProvider.nullType); |
| 4414 } |
| 4415 |
| 4416 void _assertUnknownDartObject( |
| 4417 ParameterizedType expectedType, DartObject result) { |
| 4418 expect((result as DartObjectImpl).isUnknown, isTrue); |
| 4419 expect(result.type, expectedType); |
| 4420 } |
| 4421 } |
| 4422 |
| 4423 @reflectiveTest |
| 2201 class ReferenceFinderTest { | 4424 class ReferenceFinderTest { |
| 2202 DirectedGraph<ConstantEvaluationTarget> _referenceGraph; | 4425 DirectedGraph<ConstantEvaluationTarget> _referenceGraph; |
| 2203 VariableElement _head; | 4426 VariableElement _head; |
| 2204 Element _tail; | 4427 Element _tail; |
| 2205 | 4428 |
| 2206 void setUp() { | 4429 void setUp() { |
| 2207 _referenceGraph = new DirectedGraph<ConstantEvaluationTarget>(); | 4430 _referenceGraph = new DirectedGraph<ConstantEvaluationTarget>(); |
| 2208 _head = ElementFactory.topLevelVariableElement2("v1"); | 4431 _head = ElementFactory.topLevelVariableElement2("v1"); |
| 2209 } | 4432 } |
| 2210 | 4433 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 | 4504 |
| 2282 void _visitNode(AstNode node) { | 4505 void _visitNode(AstNode node) { |
| 2283 node.accept(_createReferenceFinder(_head)); | 4506 node.accept(_createReferenceFinder(_head)); |
| 2284 } | 4507 } |
| 2285 } | 4508 } |
| 2286 | 4509 |
| 2287 class _TestAnalysisContext extends TestAnalysisContext { | 4510 class _TestAnalysisContext extends TestAnalysisContext { |
| 2288 @override | 4511 @override |
| 2289 InternalAnalysisContext getContextFor(Source source) => this; | 4512 InternalAnalysisContext getContextFor(Source source) => this; |
| 2290 } | 4513 } |
| OLD | NEW |