Ryan Dahl | 55048cd | 2011-03-10 08:54:52 | [diff] [blame] | 1 | // Copyright Joyent, Inc. and other Node contributors. |
| 2 | // |
| 3 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | // copy of this software and associated documentation files (the |
| 5 | // "Software"), to deal in the Software without restriction, including |
| 6 | // without limitation the rights to use, copy, modify, merge, publish, |
| 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 | // persons to whom the Software is furnished to do so, subject to the |
| 9 | // following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be included |
| 12 | // in all copies or substantial portions of the Software. |
| 13 | // |
| 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 22 | var common = require('../common'); |
Ryan Dahl | a0159b4 | 2010-12-04 23:20:34 | [diff] [blame] | 23 | var assert = require('assert'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 24 | var a = require('assert'); |
| 25 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 26 | function makeBlock(f) { |
| 27 | var args = Array.prototype.slice.call(arguments, 1); |
| 28 | return function() { |
| 29 | return f.apply(this, args); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 30 | }; |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 31 | } |
| 32 | |
Herbert Vojčík | cf2b206 | 2010-08-17 15:21:43 | [diff] [blame] | 33 | assert.ok(common.indirectInstanceOf(a.AssertionError.prototype, Error), |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 34 | 'a.AssertionError instanceof Error'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 35 | |
Maciej Małecki | 365fdbf | 2011-10-01 11:52:24 | [diff] [blame] | 36 | assert.throws(makeBlock(a, false), a.AssertionError, 'ok(false)'); |
| 37 | |
| 38 | assert.doesNotThrow(makeBlock(a, true), a.AssertionError, 'ok(true)'); |
| 39 | |
| 40 | assert.doesNotThrow(makeBlock(a, 'test', 'ok(\'test\')')); |
| 41 | |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 42 | assert.throws(makeBlock(a.ok, false), |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 43 | a.AssertionError, 'ok(false)'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 44 | |
| 45 | assert.doesNotThrow(makeBlock(a.ok, true), |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 46 | a.AssertionError, 'ok(true)'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 47 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 48 | assert.doesNotThrow(makeBlock(a.ok, 'test'), 'ok(\'test\')'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 49 | |
| 50 | assert.throws(makeBlock(a.equal, true, false), a.AssertionError, 'equal'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 51 | |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 52 | assert.doesNotThrow(makeBlock(a.equal, null, null), 'equal'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 53 | |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 54 | assert.doesNotThrow(makeBlock(a.equal, undefined, undefined), 'equal'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 55 | |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 56 | assert.doesNotThrow(makeBlock(a.equal, null, undefined), 'equal'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 57 | |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 58 | assert.doesNotThrow(makeBlock(a.equal, true, true), 'equal'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 59 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 60 | assert.doesNotThrow(makeBlock(a.equal, 2, '2'), 'equal'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 61 | |
| 62 | assert.doesNotThrow(makeBlock(a.notEqual, true, false), 'notEqual'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 63 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 64 | assert.throws(makeBlock(a.notEqual, true, true), |
| 65 | a.AssertionError, 'notEqual'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 66 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 67 | assert.throws(makeBlock(a.strictEqual, 2, '2'), |
| 68 | a.AssertionError, 'strictEqual'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 69 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 70 | assert.throws(makeBlock(a.strictEqual, null, undefined), |
| 71 | a.AssertionError, 'strictEqual'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 72 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 73 | assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'), 'notStrictEqual'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 74 | |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 75 | // deepEquals joy! |
| 76 | // 7.2 |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 77 | assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14), |
| 78 | new Date(2000, 3, 14)), 'deepEqual date'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 79 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 80 | assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)), |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 81 | a.AssertionError, |
| 82 | 'deepEqual date'); |
| 83 | |
| 84 | // 7.3 |
Pedro Teixeira | a805012 | 2011-02-02 11:09:02 | [diff] [blame^] | 85 | assert.doesNotThrow(makeBlock(a.deepEqual, /a/, /a/)); |
| 86 | assert.throws(makeBlock(a.deepEqual, /ab/, /a/)); |
| 87 | |
| 88 | |
| 89 | // 7.4 |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 90 | assert.doesNotThrow(makeBlock(a.deepEqual, 4, '4'), 'deepEqual == check'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 91 | assert.doesNotThrow(makeBlock(a.deepEqual, true, 1), 'deepEqual == check'); |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 92 | assert.throws(makeBlock(a.deepEqual, 4, '5'), |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 93 | a.AssertionError, |
| 94 | 'deepEqual == check'); |
| 95 | |
Pedro Teixeira | a805012 | 2011-02-02 11:09:02 | [diff] [blame^] | 96 | // 7.5 |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 97 | // having the same number of owned properties && the same set of keys |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 98 | assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4}, {a: 4})); |
| 99 | assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '2'}, {a: 4, b: '2'})); |
| 100 | assert.doesNotThrow(makeBlock(a.deepEqual, [4], ['4'])); |
| 101 | assert.throws(makeBlock(a.deepEqual, {a: 4}, {a: 4, b: true}), |
| 102 | a.AssertionError); |
| 103 | assert.doesNotThrow(makeBlock(a.deepEqual, ['a'], {0: 'a'})); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 104 | //(although not necessarily the same order), |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 105 | assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4})); |
| 106 | var a1 = [1, 2, 3]; |
| 107 | var a2 = [1, 2, 3]; |
| 108 | a1.a = 'test'; |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 109 | a1.b = true; |
| 110 | a2.b = true; |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 111 | a2.a = 'test'; |
| 112 | assert.throws(makeBlock(a.deepEqual, Object.keys(a1), Object.keys(a2)), |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 113 | a.AssertionError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 114 | assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2)); |
| 115 | |
| 116 | // having an identical prototype property |
| 117 | var nbRoot = { |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 118 | toString: function() { return this.first + ' ' + this.last; } |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 119 | }; |
| 120 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 121 | function nameBuilder(first, last) { |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 122 | this.first = first; |
| 123 | this.last = last; |
| 124 | return this; |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 125 | } |
| 126 | nameBuilder.prototype = nbRoot; |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 127 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 128 | function nameBuilder2(first, last) { |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 129 | this.first = first; |
| 130 | this.last = last; |
| 131 | return this; |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 132 | } |
| 133 | nameBuilder2.prototype = nbRoot; |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 134 | |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 135 | var nb1 = new nameBuilder('Ryan', 'Dahl'); |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 136 | var nb2 = new nameBuilder2('Ryan', 'Dahl'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 137 | |
| 138 | assert.doesNotThrow(makeBlock(a.deepEqual, nb1, nb2)); |
| 139 | |
| 140 | nameBuilder2.prototype = Object; |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 141 | nb2 = new nameBuilder2('Ryan', 'Dahl'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 142 | assert.throws(makeBlock(a.deepEqual, nb1, nb2), a.AssertionError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 143 | |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 144 | // String literal + object blew up my implementation... |
| 145 | assert.throws(makeBlock(a.deepEqual, 'a', {}), a.AssertionError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 146 | |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 147 | // Testing the throwing |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 148 | function thrower(errorConstructor) { |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 149 | throw new errorConstructor('test'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 150 | } |
Ryan Dahl | a0159b4 | 2010-12-04 23:20:34 | [diff] [blame] | 151 | var aethrow = makeBlock(thrower, a.AssertionError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 152 | aethrow = makeBlock(thrower, a.AssertionError); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 153 | |
| 154 | // the basic calls work |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 155 | assert.throws(makeBlock(thrower, a.AssertionError), |
| 156 | a.AssertionError, 'message'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 157 | assert.throws(makeBlock(thrower, a.AssertionError), a.AssertionError); |
| 158 | assert.throws(makeBlock(thrower, a.AssertionError)); |
| 159 | |
| 160 | // if not passing an error, catch all. |
| 161 | assert.throws(makeBlock(thrower, TypeError)); |
| 162 | |
| 163 | // when passing a type, only catch errors of the appropriate type |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 164 | var threw = false; |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 165 | try { |
| 166 | a.throws(makeBlock(thrower, TypeError), a.AssertionError); |
| 167 | } catch (e) { |
| 168 | threw = true; |
| 169 | assert.ok(e instanceof TypeError, 'type'); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 170 | } |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 171 | assert.equal(true, threw, |
| 172 | 'a.throws with an explicit error is eating extra errors', |
| 173 | a.AssertionError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 174 | threw = false; |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 175 | |
| 176 | // doesNotThrow should pass through all errors |
| 177 | try { |
| 178 | a.doesNotThrow(makeBlock(thrower, TypeError), a.AssertionError); |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 179 | } catch (e) { |
| 180 | threw = true; |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 181 | assert.ok(e instanceof TypeError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 182 | } |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 183 | assert.equal(true, threw, |
| 184 | 'a.doesNotThrow with an explicit error is eating extra errors'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 185 | |
| 186 | // key difference is that throwing our correct error makes an assertion error |
| 187 | try { |
| 188 | a.doesNotThrow(makeBlock(thrower, TypeError), TypeError); |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 189 | } catch (e) { |
| 190 | threw = true; |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 191 | assert.ok(e instanceof a.AssertionError); |
Karl Guertin | 4f679fd | 2009-11-30 02:20:37 | [diff] [blame] | 192 | } |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 193 | assert.equal(true, threw, |
| 194 | 'a.doesNotThrow is not catching type matching errors'); |
Ryan Dahl | dd35637 | 2009-12-29 18:37:40 | [diff] [blame] | 195 | |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 196 | assert.throws(function() {assert.ifError(new Error('test error'))}); |
| 197 | assert.doesNotThrow(function() {assert.ifError(null)}); |
| 198 | assert.doesNotThrow(function() {assert.ifError()}); |
Oleg Slobodskoi | 0208341 | 2010-11-26 23:03:31 | [diff] [blame] | 199 | |
Oleg Slobodskoi | 23cf938 | 2010-12-21 17:42:52 | [diff] [blame] | 200 | // make sure that validating using constructor really works |
| 201 | threw = false; |
| 202 | try { |
| 203 | assert.throws( |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 204 | function() { |
| 205 | throw {} |
| 206 | }, |
| 207 | Array |
Oleg Slobodskoi | 23cf938 | 2010-12-21 17:42:52 | [diff] [blame] | 208 | ); |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 209 | } catch (e) { |
Oleg Slobodskoi | 23cf938 | 2010-12-21 17:42:52 | [diff] [blame] | 210 | threw = true; |
| 211 | } |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 212 | assert.ok(threw, 'wrong constructor validation'); |
Oleg Slobodskoi | 23cf938 | 2010-12-21 17:42:52 | [diff] [blame] | 213 | |
Oleg Slobodskoi | 0208341 | 2010-11-26 23:03:31 | [diff] [blame] | 214 | // use a RegExp to validate error message |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 215 | a.throws(makeBlock(thrower, TypeError), /test/); |
Oleg Slobodskoi | 0208341 | 2010-11-26 23:03:31 | [diff] [blame] | 216 | |
| 217 | // use a fn to validate error object |
| 218 | a.throws(makeBlock(thrower, TypeError), function(err) { |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 219 | if ((err instanceof TypeError) && /test/.test(err)) { |
Oleg Slobodskoi | 23cf938 | 2010-12-21 17:42:52 | [diff] [blame] | 220 | return true; |
Oleg Efimov | 0665f02 | 2010-12-05 19:15:30 | [diff] [blame] | 221 | } |
Oleg Slobodskoi | 0208341 | 2010-11-26 23:03:31 | [diff] [blame] | 222 | }); |
Ryan Dahl | 6394ba2 | 2011-03-30 17:18:12 | [diff] [blame] | 223 | |
| 224 | |
| 225 | // GH-207. Make sure deepEqual doesn't loop forever on circular refs |
| 226 | |
| 227 | var b = {}; |
| 228 | b.b = b; |
| 229 | |
| 230 | var c = {}; |
| 231 | c.b = c; |
| 232 | |
| 233 | var gotError = false; |
| 234 | try { |
| 235 | assert.deepEqual(b, c); |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 236 | } catch (e) { |
Ryan Dahl | 6394ba2 | 2011-03-30 17:18:12 | [diff] [blame] | 237 | gotError = true; |
| 238 | } |
| 239 | |
| 240 | console.log('All OK'); |
| 241 | assert.ok(gotError); |
| 242 | |
koichik | 5f97c9a | 2011-07-10 09:47:41 | [diff] [blame] | 243 | |
| 244 | // #217 |
| 245 | function testAssertionMessage(actual, expected) { |
| 246 | try { |
| 247 | assert.equal(actual, ''); |
| 248 | } catch (e) { |
| 249 | assert.equal(e.toString(), |
Ryan Dahl | 0696e78 | 2011-08-09 21:18:16 | [diff] [blame] | 250 | ['AssertionError:', expected, '==', '""'].join(' ')); |
koichik | 5f97c9a | 2011-07-10 09:47:41 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | testAssertionMessage(undefined, '"undefined"'); |
| 254 | testAssertionMessage(null, 'null'); |
| 255 | testAssertionMessage(true, 'true'); |
| 256 | testAssertionMessage(false, 'false'); |
| 257 | testAssertionMessage(0, '0'); |
| 258 | testAssertionMessage(100, '100'); |
| 259 | testAssertionMessage(NaN, '"NaN"'); |
| 260 | testAssertionMessage(Infinity, '"Infinity"'); |
| 261 | testAssertionMessage(-Infinity, '"-Infinity"'); |
| 262 | testAssertionMessage('', '""'); |
| 263 | testAssertionMessage('foo', '"foo"'); |
| 264 | testAssertionMessage([], '[]'); |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 265 | testAssertionMessage([1, 2, 3], '[1,2,3]'); |
koichik | 5f97c9a | 2011-07-10 09:47:41 | [diff] [blame] | 266 | testAssertionMessage(/a/, '"/a/"'); |
| 267 | testAssertionMessage(/abc/gim, '"/abc/gim"'); |
| 268 | testAssertionMessage(function f() {}, '"function f() {}"'); |
| 269 | testAssertionMessage({}, '{}'); |
Colton Baker | 87286cc | 2011-10-04 22:08:18 | [diff] [blame] | 270 | testAssertionMessage({a: undefined, b: null}, '{"a":"undefined","b":null}'); |
| 271 | testAssertionMessage({a: NaN, b: Infinity, c: -Infinity}, |
koichik | 5f97c9a | 2011-07-10 09:47:41 | [diff] [blame] | 272 | '{"a":"NaN","b":"Infinity","c":"-Infinity"}'); |
| 273 | |