(ExecutionContext context, Object lhs, Object rhs)
| 549 | } |
| 550 | |
| 551 | public static boolean compareEquality(ExecutionContext context, Object lhs, Object rhs) { |
| 552 | // 11.9.3 |
| 553 | |
| 554 | if (lhs.getClass().equals(rhs.getClass()) || (lhs instanceof Number && rhs instanceof Number)) { |
| 555 | if (lhs == Types.UNDEFINED) { |
| 556 | return true; |
| 557 | } |
| 558 | if (lhs == Types.NULL) { |
| 559 | return true; |
| 560 | } |
| 561 | if (lhs instanceof Number) { |
| 562 | if (lhs instanceof Double) { |
| 563 | if (((Double) lhs).isNaN()) { |
| 564 | return false; |
| 565 | } |
| 566 | } |
| 567 | if (rhs instanceof Double) { |
| 568 | if (((Double) rhs).isNaN()) { |
| 569 | return false; |
| 570 | } |
| 571 | } |
| 572 | if (((Number) lhs).doubleValue() == ((Number) rhs) |
| 573 | .doubleValue()) { |
| 574 | return true; |
| 575 | } |
| 576 | return false; |
| 577 | } |
| 578 | if (lhs instanceof String || lhs instanceof Boolean) { |
| 579 | return lhs.equals(rhs); |
| 580 | } |
| 581 | if (lhs == rhs) { |
| 582 | return true; |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | if (lhs == Types.UNDEFINED && rhs == Types.NULL) { |
| 587 | return true; |
| 588 | } |
| 589 | |
| 590 | if (lhs == Types.NULL && rhs == Types.UNDEFINED) { |
| 591 | return true; |
| 592 | } |
| 593 | |
| 594 | if (lhs instanceof Number && rhs instanceof String) { |
| 595 | return compareEquality(context, lhs, toNumber(context, rhs)); |
| 596 | } |
| 597 | |
| 598 | if (lhs instanceof String && rhs instanceof Number) { |
| 599 | return compareEquality(context, toNumber(context, lhs), rhs); |
| 600 | } |
| 601 | |
| 602 | if (lhs instanceof Boolean) { |
| 603 | return compareEquality(context, toNumber(context, lhs), rhs); |
| 604 | } |
| 605 | |
| 606 | if (rhs instanceof Boolean) { |
| 607 | return compareEquality(context, lhs, toNumber(context, rhs)); |
| 608 | } |
no test coverage detected