                   bytearray.readBytes(bytearray3, 0, bytearray.length+1);
               }));
 
+    // Doc sez: A RangeError will be thrown if the value of offset+length exceeds 2^32-1
+    expectRangeError("RangeError in readBytes",
+                     (function () {
+                         bytearray3.position = 0;
+                         bytearray.readBytes(bytearray3, 0xFFFFFFFF, 1);
+                     }));
+
     // TODO: test more combinations of offset and count
 }
 


function testBOM() {
    var bytearray_bom:ByteArray=new ByteArray;
    bytearray_bom[0]=0xef;
    bytearray_bom[1]=0xbb;
    bytearray_bom[2]=0xbf;

    return bytearray;
}

// Utility to test for RangeError
function expectRangeError(tag, thunk)
{
    var exn_ok = "No exn";
    try                   { thunk(); }
    catch (e: RangeError) { exn_ok = "OK"; }
    catch (e)             { exn_ok = "Wrong type"; }
    AddTestCase(tag, "OK", exn_ok);
}

// Utility to test for EOFError
function expectEOF(tag, thunk)
{
