|
1 | 1 | var assert = require('assert');
|
2 | 2 | var assertEquals = assert.equal;
|
| 3 | +var assertThrows = assert['throws']; |
3 | 4 |
|
4 | 5 | require('../codepointat.js');
|
5 | 6 |
|
@@ -61,3 +62,19 @@ assertEquals('\uDF06abc'.codePointAt(false), 0xDF06);
|
61 | 62 | assertEquals('\uDF06abc'.codePointAt(NaN), 0xDF06);
|
62 | 63 | assertEquals('\uDF06abc'.codePointAt(null), 0xDF06);
|
63 | 64 | assertEquals('\uDF06abc'.codePointAt(undefined), 0xDF06);
|
| 65 | + |
| 66 | +assertThrows(function() { String.prototype.codePointAt.call(undefined); }, TypeError); |
| 67 | +assertThrows(function() { String.prototype.codePointAt.call(undefined, 4); }, TypeError); |
| 68 | +assertThrows(function() { String.prototype.codePointAt.call(null); }, TypeError); |
| 69 | +assertThrows(function() { String.prototype.codePointAt.call(null, 4); }, TypeError); |
| 70 | +assertEquals(String.prototype.codePointAt.call(42, 0), 0x34); |
| 71 | +assertEquals(String.prototype.codePointAt.call(42, 1), 0x32); |
| 72 | +assertEquals(String.prototype.codePointAt.call({ 'toString': function() { return 'abc'; } }, 2), 0x63); |
| 73 | + |
| 74 | +assertThrows(function() { String.prototype.codePointAt.apply(undefined); }, TypeError); |
| 75 | +assertThrows(function() { String.prototype.codePointAt.apply(undefined, [4]); }, TypeError); |
| 76 | +assertThrows(function() { String.prototype.codePointAt.apply(null); }, TypeError); |
| 77 | +assertThrows(function() { String.prototype.codePointAt.apply(null, [4]); }, TypeError); |
| 78 | +assertEquals(String.prototype.codePointAt.apply(42, [0]), 0x34); |
| 79 | +assertEquals(String.prototype.codePointAt.apply(42, [1]), 0x32); |
| 80 | +assertEquals(String.prototype.codePointAt.apply({ 'toString': function() { return 'abc'; } }, [2]), 0x63); |
0 commit comments