Skip to content
This repository was archived by the owner on Jun 9, 2019. It is now read-only.

Commit d2bb392

Browse files
committed
update tests for Illegal constructor
1 parent 2c5211f commit d2bb392

29 files changed

+87
-124
lines changed

test/AnalyserNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("AnalyserNode", function() {
1212

1313
assert(node instanceof global.AnalyserNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.AnalyserNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.AnalyserNode(); }, TypeError);
1918
});
2019
});
2120

test/AudioBuffer.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ describe("AudioBuffer", function() {
2323
assert.throws(function() {
2424
audioContext.createBuffer(2, 128, 44100.5);
2525
}, TypeError);
26-
27-
assert.throws(function() {
28-
return new global.AudioBuffer();
29-
}, TypeError);
26+
});
27+
it("not work when 'new' directly", function() {
28+
assert.throws(function() { new global.AudioBuffer(); }, TypeError);
3029
});
3130
});
3231

test/AudioBufferSourceNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("AudioBufferSourceNode", function() {
1212

1313
assert(node instanceof global.AudioBufferSourceNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.AudioBufferSourceNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.AudioBufferSourceNode(); }, TypeError);
1918
});
2019
});
2120

test/AudioDestinationNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("AudioDestinationNode", function() {
1212

1313
assert(node instanceof global.AudioDestinationNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.AudioDestinationNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.AudioDestinationNode(); }, TypeError);
1918
});
2019
});
2120

test/AudioListener.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ describe("AudioListener", function() {
1111
var listener = audioContext.listener;
1212

1313
assert(listener instanceof global.AudioListener);
14-
15-
assert.throws(function() {
16-
return new global.AudioListener();
17-
}, TypeError);
14+
});
15+
it("not work when 'new' directly", function() {
16+
assert.throws(function() { new global.AudioListener(); }, TypeError);
1817
});
1918
});
2019

test/AudioNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ describe("AudioNode", function() {
2323
assert(node instanceof global.AudioNode);
2424
assert(node instanceof global.EventTarget);
2525

26-
assert.throws(function() {
27-
return new global.AudioNode();
28-
}, TypeError);
29-
3026
return audioContext.close().then(function() {
3127
return immigration.apply(function(admission) {
3228
return new WebAudioTestAPI.AudioNode(admission, { context: audioContext });
@@ -37,6 +33,9 @@ describe("AudioNode", function() {
3733
assert(e instanceof TypeError && /audioContext has been closed/i.test(e.message));
3834
});
3935
});
36+
it("not work when 'new' directly", function() {
37+
assert.throws(function() { new global.AudioNode(); }, TypeError);
38+
});
4039
});
4140

4241
describe("#context: AudioContext", function() {

test/AudioParam.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ describe("AudioParam", function() {
1919

2020
assert(param instanceof global.AudioParam);
2121

22-
assert.throws(function() {
23-
return new global.AudioParam();
24-
}, TypeError);
25-
2622
// test api
2723
assert(param.$node === node);
2824
});
25+
it("not work when 'new' directly", function() {
26+
assert.throws(function() { new global.AudioParam(); }, TypeError);
27+
});
2928
});
3029

3130
describe("#name: string", function() {

test/AudioProcessingEvent.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ describe("AudioProcessingEvent", function() {
2020
assert(event instanceof global.AudioProcessingEvent);
2121
assert(event instanceof global.Event);
2222

23-
assert.throws(function() {
24-
return new global.AudioProcessingEvent();
25-
}, TypeError);
26-
2723
// test api
2824
assert(event.$name === "AudioProcessingEvent");
2925
assert(event.$node === node);
3026
});
27+
it("not work when 'new' directly", function() {
28+
assert.throws(function() { new global.AudioProcessingEvent(); }, TypeError);
29+
});
3130
});
3231
});

test/BiquadFilterNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("BiquadFilterNode", function() {
1212

1313
assert(node instanceof global.BiquadFilterNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.BiquadFilterNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.BiquadFilterNode(); }, TypeError);
1918
});
2019
});
2120

test/ChannelMergerNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ describe("ChannelMergerNode", function() {
1616
assert.throws(function() {
1717
audioContext.createChannelMerger(5.1);
1818
}, TypeError);
19-
20-
assert.throws(function() {
21-
return new global.ChannelMergerNode();
22-
}, TypeError);
19+
});
20+
it("not work when 'new' directly", function() {
21+
assert.throws(function() { new global.ChannelMergerNode(); }, TypeError);
2322
});
2423
});
2524

test/ChannelSplitterNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ describe("ChannelSplitterNode", function() {
1616
assert.throws(function() {
1717
audioContext.createChannelSplitter(5.1);
1818
}, TypeError);
19-
20-
assert.throws(function() {
21-
return new global.ChannelSplitterNode();
22-
}, TypeError);
19+
});
20+
it("not work when 'new' directly", function() {
21+
assert.throws(function() { new global.ChannelSplitterNode(); }, TypeError);
2322
});
2423
});
2524

test/ConvolverNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("ConvolverNode", function() {
1212

1313
assert(node instanceof global.ConvolverNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.ConvolverNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.ConvolverNode(); }, TypeError);
1918
});
2019
});
2120

test/DelayNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ describe("DelayNode", function() {
2424
assert.throws(function() {
2525
audioContext.createDelay(undefined);
2626
}, TypeError);
27-
28-
assert.throws(function() {
29-
return new global.DelayNode();
30-
}, TypeError);
27+
});
28+
it("not work when 'new' directly", function() {
29+
assert.throws(function() { new global.DelayNode(); }, TypeError);
3130
});
3231
});
3332

test/DynamicsCompressorNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("DynamicsCompressorNode", function() {
1212

1313
assert(node instanceof global.DynamicsCompressorNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.DynamicsCompressorNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.DynamicsCompressorNode(); }, TypeError);
1918
});
2019
});
2120

test/GainNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("GainNode", function() {
1212

1313
assert(node instanceof global.GainNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.GainNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.GainNode(); }, TypeError);
1918
});
2019
});
2120

test/MediaElementAudioSourceNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ describe("MediaElementAudioSourceNode", function() {
1717
assert.throws(function() {
1818
audioContext.createMediaElementSource("INVALID");
1919
}, TypeError);
20-
21-
assert.throws(function() {
22-
return new global.MediaElementAudioSourceNode();
23-
}, TypeError);
20+
});
21+
it("not work when 'new' directly", function() {
22+
assert.throws(function() { new global.MediaElementAudioSourceNode(); }, TypeError);
2423
});
2524
});
2625

test/MediaStreamAudioDestinationNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("MediaStreamAudioDestinationNode", function() {
1212

1313
assert(node instanceof global.MediaStreamAudioDestinationNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.MediaStreamAudioDestinationNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.MediaStreamAudioDestinationNode(); }, TypeError);
1918
});
2019
});
2120

test/MediaStreamAudioSourceNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ describe("MediaStreamAudioSourceNode", function() {
1717
assert.throws(function() {
1818
audioContext.createMediaStreamSource("INVALID");
1919
}, TypeError);
20-
21-
assert.throws(function() {
22-
return new global.MediaStreamAudioSourceNode();
23-
}, TypeError);
20+
});
21+
it("not work when 'new' directly", function() {
22+
assert.throws(function() { new global.MediaStreamAudioSourceNode(); }, TypeError);
2423
});
2524
});
2625

test/OfflineAudioCompletionEvent.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ describe("OfflineAudioCompletionEvent", function() {
2020
assert(event instanceof global.OfflineAudioCompletionEvent);
2121
assert(event instanceof global.Event);
2222

23-
assert.throws(function() {
24-
return new global.OfflineAudioCompletionEvent();
25-
}, TypeError);
26-
2723
// test api
2824
assert(event.$name === "OfflineAudioCompletionEvent");
2925
assert(event.$node === node);
3026
});
27+
it("not work when 'new' directly", function() {
28+
assert.throws(function() { new global.OfflineAudioCompletionEvent(); }, TypeError);
29+
});
3130
});
3231
});

test/OscillatorNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("OscillatorNode", function() {
1212

1313
assert(node instanceof global.OscillatorNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.OscillatorNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.OscillatorNode(); }, TypeError);
1918
});
2019
});
2120

test/PannerNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ describe("PannerNode", function() {
1212

1313
assert(node instanceof global.PannerNode);
1414
assert(node instanceof global.AudioNode);
15-
16-
assert.throws(function() {
17-
return new global.PannerNode();
18-
}, TypeError);
15+
});
16+
it("not work when 'new' directly", function() {
17+
assert.throws(function() { new global.PannerNode(); }, TypeError);
1918
});
2019
});
2120

test/PeriodicWave.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ describe("PeriodicWave", function() {
3636
assert.throws(function() {
3737
audioContext.createPeriodicWave(f128, f8192);
3838
}, TypeError);
39-
40-
assert.throws(function() {
41-
return new global.PeriodicWave();
42-
}, TypeError);
39+
});
40+
it("not work when 'new' directly", function() {
41+
assert.throws(function() { new global.PeriodicWave(); }, TypeError);
4342
});
4443
});
4544

test/ScriptProcessorNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ describe("ScriptProcessorNode", function() {
3636
assert.throws(function() {
3737
audioContext.createScriptProcessor(1024, 1, undefined);
3838
}, TypeError);
39-
40-
assert.throws(function() {
41-
return new global.ScriptProcessorNode();
42-
}, TypeError);
39+
});
40+
it("not work when 'new' directly", function() {
41+
assert.throws(function() { new global.ScriptProcessorNode(256, 1, 1); }, TypeError);
4342
});
4443
});
4544

test/StereoPannerNode.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ describe("StereoPannerNode", function() {
2020

2121
assert(node instanceof global.StereoPannerNode);
2222
assert(node instanceof global.AudioNode);
23-
24-
assert.throws(function() {
25-
return new global.StereoPannerNode();
26-
}, TypeError);
23+
});
24+
it("not work when 'new' directly", function() {
25+
assert.throws(function() { new global.StereoPannerNode(); }, TypeError);
2726
});
2827
});
2928

test/dom/Element.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ describe("Element", function() {
66
var element = new WebAudioTestAPI.Element();
77

88
assert(element instanceof global.window.Element);
9-
10-
assert.throws(function() {
11-
return new global.Element();
12-
}, function(e) {
13-
return e instanceof TypeError;
14-
});
9+
});
10+
it("not work when 'new' directly", function() {
11+
assert.throws(function() { new global.Element(); }, TypeError);
1512
});
1613
});
1714
});

test/dom/EventTarget.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ describe("EventTarget", function() {
66
var target = new WebAudioTestAPI.EventTarget();
77

88
assert(target instanceof global.window.EventTarget);
9-
10-
assert.throws(function() {
11-
return new global.EventTarget();
12-
}, TypeError);
9+
});
10+
it("not work when 'new' directly", function() {
11+
assert.throws(function() { new global.EventTarget(); }, TypeError);
1312
});
1413
});
1514

test/dom/HTMLElement.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ describe("HTMLElement", function() {
77

88
assert(element instanceof global.window.HTMLElement);
99
assert(element instanceof global.window.Element);
10-
11-
assert.throws(function() {
12-
return new global.HTMLElement();
13-
}, function(e) {
14-
return e instanceof TypeError;
15-
});
10+
});
11+
it("not work when 'new' directly", function() {
12+
assert.throws(function() { new global.HTMLElement(); }, TypeError);
1613
});
1714
});
1815
});

0 commit comments

Comments
 (0)