| 1 |
// Test that setting Debugger.Memory.prototype.allocationSamplingProbability to |
| 2 |
// a bad number throws. |
| 3 |
|
| 4 |
load(libdir + "asserts.js"); |
| 5 |
|
| 6 |
const root = newGlobal({newCompartment: true}); |
| 7 |
|
| 8 |
const dbg = new Debugger(); |
| 9 |
const wrappedRoot = dbg.addDebuggee(root); |
| 10 |
|
| 11 |
var mem = dbg.memory; |
| 12 |
|
| 13 |
// Out of range, negative |
| 14 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = -Number.MAX_VALUE, |
| 15 |
TypeError); |
| 16 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = -1, |
| 17 |
TypeError); |
| 18 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = -Number.MIN_VALUE, |
| 19 |
TypeError); |
| 20 |
|
| 21 |
// In range |
| 22 |
mem.allocationSamplingProbability = -0.0; |
| 23 |
mem.allocationSamplingProbability = 0.0; |
| 24 |
mem.allocationSamplingProbability = Number.MIN_VALUE; |
| 25 |
mem.allocationSamplingProbability = 1 / 3; |
| 26 |
mem.allocationSamplingProbability = .5; |
| 27 |
mem.allocationSamplingProbability = 2 / 3; |
| 28 |
mem.allocationSamplingProbability = 1 - Math.pow(2, -53); |
| 29 |
mem.allocationSamplingProbability = 1; |
| 30 |
|
| 31 |
// Out of range, positive |
| 32 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = 1 + Number.EPSILON, |
| 33 |
TypeError); |
| 34 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = 2, |
| 35 |
TypeError); |
| 36 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = Number.MAX_VALUE, |
| 37 |
TypeError); |
| 38 |
|
| 39 |
// Out of range, non-finite |
| 40 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = -Infinity, |
| 41 |
TypeError); |
| 42 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = Infinity, |
| 43 |
TypeError); |
| 44 |
assertThrowsInstanceOf(() => mem.allocationSamplingProbability = NaN, |
| 45 |
TypeError); |