Skip to content

Commit

Permalink
more on error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 31, 2025
1 parent f64b322 commit 838ad52
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void sliceInvalidStartIndexNumberString() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void sliceInvalidStartIndexDouble() throws Exception {
sliceInvalidIndex("2.14");
}
Expand All @@ -151,7 +151,7 @@ public void sliceInvalidStartIndexString() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("RangeError")
public void sliceInvalidStartIndexTrue() throws Exception {
sliceInvalidIndex("true");
}
Expand Down Expand Up @@ -253,9 +253,7 @@ private void sliceInvalidIndex(final String index) throws Exception {
+ " for(var i = 0; i < y.length; i++) {\n"
+ " log(y[i]);\n"
+ " }\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ public void ctorInvalidValuesFloat() throws Exception {
+ " for(var i = 0; i < x.length; i++) {\n"
+ " log(x[i]);\n"
+ " }\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public void arrayConstruction() throws Exception {
+ " x.setFloat32(1, Math.PI);\n"
+ " log(x.getInt8(0));\n"
+ " log(x.getFloat32(1));\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -82,9 +80,7 @@ public void endian() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -110,9 +106,7 @@ public void uint16() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -124,7 +118,7 @@ public void uint16() throws Exception {
* @throws Exception if the test fails
*/
@Test
@Alerts("exception")
@Alerts("TypeError")
public void nullConstructor() throws Exception {
final String html
= "<html><head>\n"
Expand All @@ -133,9 +127,7 @@ public void nullConstructor() throws Exception {
+ "function test() {\n"
+ " try {\n"
+ " new DataView(null);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public void bufferConstructor() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -180,9 +178,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Float32Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public void bufferConstructor() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -180,9 +178,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Float64Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public void buffer() throws Exception {
+ " log(array.buffer);\n"
+ " log(array.byteLength);\n"
+ " log(array.byteOffset);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -73,9 +71,7 @@ public void arrayConstructor() throws Exception {
+ " log(array[0]);\n"
+ " log(array[1]);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -96,9 +92,7 @@ public void constant() throws Exception {
+ "function test() {\n"
+ " try {\n"
+ " log(Int16Array.BYTES_PER_ELEMENT);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -122,9 +116,7 @@ public void bufferConstructor() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -149,9 +141,7 @@ public void outOfRange() throws Exception {
+ " array[1] = 12;\n"
+ " array[2] = 13;\n"
+ " log(array[2]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -282,9 +272,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Int16Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public void bufferConstructor() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -180,9 +178,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Int32Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public void buffer() throws Exception {
+ " log(array.buffer);\n"
+ " log(array.byteLength);\n"
+ " log(array.byteOffset);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -74,9 +72,7 @@ public void arrayConstructor() throws Exception {
+ " log(array[0]);\n"
+ " log(array[1]);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -121,9 +117,7 @@ public void constant() throws Exception {
+ "function test() {\n"
+ " try {\n"
+ " log(Int8Array.BYTES_PER_ELEMENT);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -254,9 +248,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Int8Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ private void sliceInvalidIndex(final String index) throws Exception {
+ " for(var i = 0; i < y.length; i++) {\n"
+ " log(y[i]);\n"
+ " }\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public void arrayConstruction() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -181,9 +179,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Uint16Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public void arrayConstruction() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -71,9 +69,7 @@ public void constant() throws Exception {
+ "function test() {\n"
+ " try {\n"
+ " log(Uint32Array.BYTES_PER_ELEMENT);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -204,9 +200,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Uint32Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public void arrayConstruction() throws Exception {
+ " var array2 = new Int8Array(array.buffer);\n"
+ " for (var i = 0; i < array2.length; i++)\n"
+ " log(array2[i]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -181,9 +179,7 @@ public void nullConstructor() throws Exception {
+ " try {\n"
+ " var array = new Uint8Array(null);\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down Expand Up @@ -211,9 +207,7 @@ public void defineProperty() throws Exception {
+ " });\n"
+ " log(array);\n"
+ " log(array[Symbol]);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand All @@ -235,9 +229,7 @@ public void emptyConstructor() throws Exception {
+ " try {\n"
+ " var array = new Uint8Array();\n"
+ " log(array.length);\n"
+ " } catch(e) {\n"
+ " log('exception');\n"
+ " }\n"
+ " } catch(e) {log(e.name);}\n"
+ "}\n"
+ "</script></head><body onload='test()'>\n"
+ "</body></html>";
Expand Down
Loading

0 comments on commit 838ad52

Please sign in to comment.