| 98 | } |
| 99 | |
| 100 | function shouldBe(_a, _b) |
| 101 | { |
| 102 | if (typeof _a != "string" || typeof _b != "string") |
| 103 | debug("WARN: shouldBe() expects string arguments"); |
| 104 | var exception; |
| 105 | var _av; |
| 106 | try { |
| 107 | _av = eval(_a); |
| 108 | } catch (e) { |
| 109 | exception = e; |
| 110 | } |
| 111 | var _bv = eval(_b); |
| 112 | |
| 113 | if (exception) |
| 114 | testFailed(_a + " should be " + _bv + ". Threw exception " + exception); |
| 115 | else if (isResultCorrect(_av, _bv)) |
| 116 | testPassed(_a + " is " + _b); |
| 117 | else if (typeof(_av) == typeof(_bv)) |
| 118 | testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + "."); |
| 119 | else |
| 120 | testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + stringify(_av) + " (of type " + typeof _av + ")."); |
| 121 | } |
| 122 | |
| 123 | function shouldBeTrue(_a) { shouldBe(_a, "true"); } |
| 124 | function shouldBeFalse(_a) { shouldBe(_a, "false"); } |