ticaiolima@gmail.com | 77f1746 | 2018-12-13 12:26:01 +0000 | [diff] [blame] | 1 | let assert = { |
| 2 | sameValue: function(i, e, m) { |
| 3 | if (i !== e) |
| 4 | throw new Error(m); |
| 5 | } |
| 6 | } |
| 7 | |
| 8 | function bigIntDiv(x, y) { |
| 9 | return x / y; |
| 10 | } |
| 11 | noInline(bigIntDiv); |
| 12 | |
| 13 | let o = {valueOf: () => 10n}; |
| 14 | |
| 15 | for (let i = 0; i < 10000; i++) { |
| 16 | let r = bigIntDiv(30n, o); |
| 17 | assert.sameValue(r, 3n, 30n + " / {valueOf: () => 10n} = " + r); |
| 18 | } |
| 19 | |
| 20 | o2 = {valueOf: () => 10000n}; |
| 21 | |
| 22 | for (let i = 0; i < 10000; i++) { |
| 23 | let r = bigIntDiv(o2, o); |
| 24 | assert.sameValue(r, 1000n, "{valueOf: () => 10000n} / {valueOf: () => 10n} = " + r); |
| 25 | } |
| 26 | |
| 27 | o = Object(10n); |
| 28 | let r = bigIntDiv(30n, o); |
| 29 | assert.sameValue(r, 3n, 30n + " / Object(10n) = " + r); |
| 30 | |
| 31 | o2 = Object(3240n); |
| 32 | r = bigIntDiv(o2, o); |
| 33 | assert.sameValue(r, 324n, "Object(3240n) / Object(10n) = " + r); |
| 34 | |