tests: Port avmplus ByteArray tests

This commit is contained in:
Nathan Adams 2023-07-27 09:58:17 +02:00
parent 7dc0224451
commit 0d1d110660
15 changed files with 3419 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,425 @@
ByteArray constructor no args PASSED!
ByteArray length of empty PASSED!
ByteArray toString empty PASSED!
ByteArray available on empty PASSED!
ByteArray position on empty PASSED!
ByteArray endianness on empty PASSED!
ByteArray trivial length PASSED!
ByteArray trivial position PASSED!
ByteArray position after clearing PASSED!
ByteArray position can exceed length, #1 PASSED!
ByteArray position can exceed length, #2 PASSED!
ByteArray position can exceed length, #3 PASSED!
ByteArray position can exceed length, #4 PASSED!
ByteArray position can exceed length, #5 PASSED!
ByteArray position can exceed length, #6 PASSED!
ByteArray position after writing Booleans PASSED!
ByteArray move position to 0 PASSED!
ByteArray write/read boolean true PASSED!
ByteArray write/read boolean false PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
ByteArray readShort_3 #1 0 1 PASSED!
ByteArray readShort_3 #1 0 2 PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
ByteArray readShort_3 #1 1 1 PASSED!
ByteArray readShort_3 #1 1 2 PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
ByteArray readShort_3 #1 2 1 PASSED!
ByteArray readShort_3 #1 2 2 PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
ByteArray readShort_3 #1 3 1 PASSED!
ByteArray readShort_3 #1 3 2 PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
ByteArray readUShort_3 #1 0 1 PASSED!
ByteArray readUShort_3 #1 0 2 PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
ByteArray readUShort_3 #1 1 1 PASSED!
ByteArray readUShort_3 #1 1 2 PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
ByteArray readUShort_3 #1 2 1 PASSED!
ByteArray readUShort_3 #1 2 2 PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
ByteArray readUShort_3 #1 3 1 PASSED!
ByteArray readUShort_3 #1 3 2 PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
ByteArray readInt_3 #1 0 1 PASSED!
ByteArray readInt_3 #1 0 2 PASSED!
ByteArray readInt_3 #1 0 3 PASSED!
ByteArray readInt_3 #1 0 4 PASSED!
ByteArray readInt_3 #2 at position=2^32-16 PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
ByteArray readInt_3 #1 1 1 PASSED!
ByteArray readInt_3 #1 1 2 PASSED!
ByteArray readInt_3 #1 1 3 PASSED!
ByteArray readInt_3 #1 1 4 PASSED!
ByteArray readInt_3 #2 at position=2^32-16 PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
ByteArray readInt_3 #1 2 1 PASSED!
ByteArray readInt_3 #1 2 2 PASSED!
ByteArray readInt_3 #1 2 3 PASSED!
ByteArray readInt_3 #1 2 4 PASSED!
ByteArray readInt_3 #2 at position=2^32-16 PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
ByteArray readInt_3 #1 3 1 PASSED!
ByteArray readInt_3 #1 3 2 PASSED!
ByteArray readInt_3 #1 3 3 PASSED!
ByteArray readInt_3 #1 3 4 PASSED!
ByteArray readInt_3 #2 at position=2^32-16 PASSED!
ByteArray readUnsignedInt_1 #1 bigEndian PASSED!
ByteArray readUnsignedInt_1 #2 bigEndian PASSED!
ByteArray readUnsignedInt_1 #3bigEndian PASSED!
ByteArray readUnsignedInt_1 #1 littleEndian PASSED!
ByteArray readUnsignedInt_1 #2 littleEndian PASSED!
ByteArray readUnsignedInt_1 #3littleEndian PASSED!
ByteArray readUnsignedInt_2 #1 PASSED!
ByteArray readUnsignedInt_2 #2 PASSED!
ByteArray readUnsignedInt_2 #3 PASSED!
ByteArray readUInt_3 #1 0 1 PASSED!
ByteArray readUInt_3 #1 0 2 PASSED!
ByteArray readUInt_3 #1 0 3 PASSED!
ByteArray readUInt_3 #1 0 4 PASSED!
ByteArray readUnsignedInt_1 #1 bigEndian PASSED!
ByteArray readUnsignedInt_1 #2 bigEndian PASSED!
ByteArray readUnsignedInt_1 #3bigEndian PASSED!
ByteArray readUnsignedInt_1 #1 littleEndian PASSED!
ByteArray readUnsignedInt_1 #2 littleEndian PASSED!
ByteArray readUnsignedInt_1 #3littleEndian PASSED!
ByteArray readUnsignedInt_2 #1 PASSED!
ByteArray readUnsignedInt_2 #2 PASSED!
ByteArray readUnsignedInt_2 #3 PASSED!
ByteArray readUInt_3 #1 1 1 PASSED!
ByteArray readUInt_3 #1 1 2 PASSED!
ByteArray readUInt_3 #1 1 3 PASSED!
ByteArray readUInt_3 #1 1 4 PASSED!
ByteArray readUnsignedInt_1 #1 bigEndian PASSED!
ByteArray readUnsignedInt_1 #2 bigEndian PASSED!
ByteArray readUnsignedInt_1 #3bigEndian PASSED!
ByteArray readUnsignedInt_1 #1 littleEndian PASSED!
ByteArray readUnsignedInt_1 #2 littleEndian PASSED!
ByteArray readUnsignedInt_1 #3littleEndian PASSED!
ByteArray readUnsignedInt_2 #1 PASSED!
ByteArray readUnsignedInt_2 #2 PASSED!
ByteArray readUnsignedInt_2 #3 PASSED!
ByteArray readUInt_3 #1 2 1 PASSED!
ByteArray readUInt_3 #1 2 2 PASSED!
ByteArray readUInt_3 #1 2 3 PASSED!
ByteArray readUInt_3 #1 2 4 PASSED!
ByteArray readUnsignedInt_1 #1 bigEndian PASSED!
ByteArray readUnsignedInt_1 #2 bigEndian PASSED!
ByteArray readUnsignedInt_1 #3bigEndian PASSED!
ByteArray readUnsignedInt_1 #1 littleEndian PASSED!
ByteArray readUnsignedInt_1 #2 littleEndian PASSED!
ByteArray readUnsignedInt_1 #3littleEndian PASSED!
ByteArray readUnsignedInt_2 #1 PASSED!
ByteArray readUnsignedInt_2 #2 PASSED!
ByteArray readUnsignedInt_2 #3 PASSED!
ByteArray readUInt_3 #1 3 1 PASSED!
ByteArray readUInt_3 #1 3 2 PASSED!
ByteArray readUInt_3 #1 3 3 PASSED!
ByteArray readUInt_3 #1 3 4 PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
ByteArray readFloat_3 #1 0 1 PASSED!
ByteArray readFloat_3 #1 0 2 PASSED!
ByteArray readFloat_3 #1 0 3 PASSED!
ByteArray readFloat_3 #1 0 4 PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
ByteArray readFloat_3 #1 1 1 PASSED!
ByteArray readFloat_3 #1 1 2 PASSED!
ByteArray readFloat_3 #1 1 3 PASSED!
ByteArray readFloat_3 #1 1 4 PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
ByteArray readFloat_3 #1 2 1 PASSED!
ByteArray readFloat_3 #1 2 2 PASSED!
ByteArray readFloat_3 #1 2 3 PASSED!
ByteArray readFloat_3 #1 2 4 PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
ByteArray readFloat_3 #1 3 1 PASSED!
ByteArray readFloat_3 #1 3 2 PASSED!
ByteArray readFloat_3 #1 3 3 PASSED!
ByteArray readFloat_3 #1 3 4 PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
ByteArray readDouble_3 #1 0 1 PASSED!
ByteArray readDouble_3 #1 0 2 PASSED!
ByteArray readDouble_3 #1 0 3 PASSED!
ByteArray readDouble_3 #1 0 4 PASSED!
ByteArray readDouble_3 #1 0 5 PASSED!
ByteArray readDouble_3 #1 0 6 PASSED!
ByteArray readDouble_3 #1 0 7 PASSED!
ByteArray readDouble_3 #1 0 8 PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
ByteArray readDouble_3 #1 1 1 PASSED!
ByteArray readDouble_3 #1 1 2 PASSED!
ByteArray readDouble_3 #1 1 3 PASSED!
ByteArray readDouble_3 #1 1 4 PASSED!
ByteArray readDouble_3 #1 1 5 PASSED!
ByteArray readDouble_3 #1 1 6 PASSED!
ByteArray readDouble_3 #1 1 7 PASSED!
ByteArray readDouble_3 #1 1 8 PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
ByteArray readDouble_3 #1 2 1 PASSED!
ByteArray readDouble_3 #1 2 2 PASSED!
ByteArray readDouble_3 #1 2 3 PASSED!
ByteArray readDouble_3 #1 2 4 PASSED!
ByteArray readDouble_3 #1 2 5 PASSED!
ByteArray readDouble_3 #1 2 6 PASSED!
ByteArray readDouble_3 #1 2 7 PASSED!
ByteArray readDouble_3 #1 2 8 PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
ByteArray readDouble_3 #1 3 1 PASSED!
ByteArray readDouble_3 #1 3 2 PASSED!
ByteArray readDouble_3 #1 3 3 PASSED!
ByteArray readDouble_3 #1 3 4 PASSED!
ByteArray readDouble_3 #1 3 5 PASSED!
ByteArray readDouble_3 #1 3 6 PASSED!
ByteArray readDouble_3 #1 3 7 PASSED!
ByteArray readDouble_3 #1 3 8 PASSED!
testByte: ByteArray position PASSED!
testByte: ByteArray length PASSED!
ByteArray readByte PASSED!
ByteArray readByte PASSED!
ByteArray readByte EOF PASSED!
testUnsignedByte: ByteArray position PASSED!
testUnsignedByte: ByteArray length PASSED!
ByteArray readUnsignedByte PASSED!
ByteArray readUnsignedByte PASSED!
ByteArray readUnsignedByte EOF PASSED!
ByteArray position of utf string PASSED!
ByteArray length of utf string PASSED!
ByteArray readUTF PASSED!
ByteArray readUTF on contents containing NUL: contents PASSED!
ByteArray readUTF on contents containing NUL: position PASSED!
ReadUTF EOF in content PASSED!
ReadUTF EOF in length, #1 PASSED!
ReadUTF EOF in length, #2 PASSED!
RangeError in writeUTF PASSED!
ByteArray readUTF skips UTF8 BOM after length bytes but includes it in the length PASSED!
ByteArray length of utf bytes string PASSED!
ByteArray readUTFBytes PASSED!
ByteArray readUTFBytes on contents containing NUL: contents PASSED!
ByteArray readUTFBytes on contents containing NUL: position PASSED!
ReadUTFBytes EOF in content PASSED!
ByteArray readUTFBytes skips UTF8 BOM but includes it in the length PASSED!
get default endian PASSED!
set endian littleEndian PASSED!
set endian bigEndian PASSED!
exception thrown when endian is to littleEndian or bigEndian PASSED!
endian value is uchanged after invalid set PASSED!
ByteArray get [] syntax PASSED!
ByteArray set [] syntax PASSED!
ByteArray set [] / get [] syntax PASSED!
Bytearray get[] out of range PASSED!
ByteArray set[] out of range: changed element PASSED!
ByteArray set[] out of range: length PASSED!
ByteArray set[] out of range: zero-fill PASSED!
ByteArray get[] and set[]: position PASSED!
ByteArray set[] with Atom index PASSED!
ByteArray get[] with Atom index PASSED!
ByteArray empty slots filled with 0 PASSED!
ByteArray shrink length PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
readBytes correct content PASSED!
ByteArray readBytes 8 length copies values, check size PASSED!
ByteArray readBytes 8 length copies values, check position PASSED!
EOF in readBytes PASSED!
RangeError in readBytes PASSED!
ByteArray writeBytes: length PASSED!
ByteArray writeBytes: position PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes: content PASSED!
ByteArray writeBytes PASSED!
ByteArray hasAtomProperty true PASSED!
ByteArray hasAtomProperty false PASSED!
ByteArray with bom toString PASSED!
ByteArray with no bom toString PASSED!
ByteArray with partial bad utf-8 sequence PASSED!
ByteArray with truncated utf-8 sequence PASSED!
ByteArray with out-of-range utf-8 sequence PASSED!
ByteArray.compress bytearray length is different PASSED!
ByteArray.compress bytearray contents differ PASSED!
ByteArray.uncompress bytearray length matches before compress PASSED!
ByteArray.uncompress uncompressing compressed string matches original PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true

View File

@ -0,0 +1,924 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
/* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// General principles for this test suite:
//
// - never write just one, write at least two (to test that position
// advances correctly and output is placed correctly)
// - ditto read
// - test both little and big endian for multibyte data
// - test both aligned and unaligned access for multibyte data
//
// Search for "TODO" for comments about missing tests.
package {
import flash.display.MovieClip;
public class Test extends MovieClip {}
}
import flash.errors.EOFError;
import flash.errors.IOError;
import flash.errors.MemoryError;
import flash.utils.ByteArray;
import flash.utils.CompressionAlgorithm;
import com.adobe.test.Assert;
// var SECTION = "ByteArrayWithLzmaTemplate";
// var VERSION = "as3";
// var TITLE = "test ByteArray class with lzma";
// Utility to make and pad a ByteArray
function makeByteArray(padding=0) : ByteArray
{
var bytearray:ByteArray=new ByteArray();
for ( var i=0 ; i < padding ; i++ )
bytearray.writeByte(0);
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"; }
Assert.expectEq(tag, "OK", exn_ok);
}
// Utility to test for EOFError
function expectEOF(tag, thunk)
{
var exn_ok = "No exn";
try { thunk(); }
catch (e: EOFError) { exn_ok = "OK"; }
catch (e) { exn_ok = "Wrong type"; }
Assert.expectEq(tag, "OK", exn_ok);
}
// Utility to test for IOError
function expectIOError(tag, thunk)
{
var exn_ok = "No exn";
try { thunk(); }
catch (e: IOError) { exn_ok = "OK"; }
catch (e) { exn_ok = "Wrong type"; }
Assert.expectEq(tag, "OK", exn_ok);
}
function callCompress(byteArray:ByteArray,description:String):void
{
var error_status:String='no error';
var len:int = byteArray.length;
try
{
byteArray.compress(CompressionAlgorithm.LZMA);
byteArray.uncompress(CompressionAlgorithm.LZMA);
}
catch(error:Error)
{
error_status = error.message;
}
byteArray.position = len;
Assert.expectEq(description+": expecting no exception","no error",error_status);
Assert.expectEq(description+": expecting length no change ",len,byteArray.length);
}
function testEmptyByteArrayWithLzma()
{
var bytearray:ByteArray = new ByteArray();
callCompress(bytearray,"empty bytearray");
}
testEmptyByteArrayWithLzma();
function zeroByteArrayWithLzma()
{
var bytearray:ByteArray = new ByteArray();
bytearray.writeByte(0);
callCompress(bytearray,"zero length bytearray");
}
zeroByteArrayWithLzma();
function nullByteArrayWithLzma()
{
var byteArray:ByteArray = null;
var error_status:String='no error';
try
{
byteArray.compress(CompressionAlgorithm.LZMA);
byteArray.uncompress(CompressionAlgorithm.LZMA);
}
catch(error:Error)
{
error_status ='error';
}
Assert.expectEq("expecting thrown exception","error",error_status);
}
nullByteArrayWithLzma();
function compressWithZlibUncompressLzma()
{
var byteArray:ByteArray = new ByteArray();
byteArray.writeUTF("COMPRESS TEST");
var error_status:String = 'no error';
try
{
byteArray.compress(CompressionAlgorithm.ZLIB)
byteArray.uncompress(CompressionAlgorithm.LZMA);
}
catch(error:Error)
{
error_status ='error';
}
Assert.expectEq("expecting thrown exception compressWithZlibUncompressLzma", "error", error_status);
}
compressWithZlibUncompressLzma()
function uncompressWithoutCompressionLzma()
{
var byteArray:ByteArray = new ByteArray();
byteArray.writeUTF("UNCOMPRESS TEST");
var uncompressedLengthBefore : uint = byteArray.length;
var error_status:String = 'no error';
try
{
byteArray.uncompress(CompressionAlgorithm.LZMA);
}
catch(error:IOError)
{
error_status ='error';
}
catch(error:MemoryError)
{
error_status ='error';
}
Assert.expectEq("expecting thrown exception uncompressWithZlibUncompressLzma", "error", error_status);
Assert.expectEq("uncompressWithoutCompressionLzma bytearray length matches before uncompress",
uncompressedLengthBefore, byteArray.length);
}
uncompressWithoutCompressionLzma()
function testBooleanWithLzma()
{
var bytearray:ByteArray=makeByteArray();
bytearray.writeBoolean(true);
bytearray.writeBoolean(false);
Assert.expectEq("ByteArray position after writing Booleans",
2,
bytearray.position);
callCompress(bytearray,"boolean bytearray");
bytearray.position=0;
Assert.expectEq(
"ByteArray move position to 0",
0,
bytearray.position);
Assert.expectEq(
"ByteArray write/read boolean true",
true,
bytearray.readBoolean());
Assert.expectEq(
"ByteArray write/read boolean false",
false,
bytearray.readBoolean());
}
testBooleanWithLzma();
function testShortWithLzma()
{
// One endianness or the other
function readShort_tests1(endian, offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = endian;
bytearray.position=offset;
bytearray.writeShort(100);
bytearray.writeShort(-200);
callCompress(bytearray,"bytearray of short");
bytearray.position=offset;
Assert.expectEq("ByteArray readShort_1 #1 " + endian,
100,
bytearray.readShort());
Assert.expectEq( "ByteArray readShort_1 #2 " + endian,
-200,
bytearray.readShort());
Assert.expectEq("ByteArray readShort_1 #3" + endian,
4+offset,
bytearray.position);
}
// Mixed endianness: write with one, read with the other
function readShort_tests2(offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = "bigEndian";
bytearray.position=offset;
bytearray.writeShort(int(0x1234));
bytearray.writeShort(int(0xFEDC));
callCompress(bytearray,"bytearray of short mixed endianness");
bytearray.position=offset;
bytearray.endian = "littleEndian";
Assert.expectEq("ByteArray readShort_2 #1",
int(0x3412),
bytearray.readShort());
Assert.expectEq("ByteArray readShort_2 #2",
int(0xFFFFDCFE), // Sign extended
bytearray.readShort());
Assert.expectEq("ByteArray readShort_2 #3",
4+offset,
bytearray.position);
}
// EOF at various offsets and alignments
function readShort_tests3(offset)
{
var bytearray:ByteArray=makeByteArray(offset); // use offset to create the alignment
bytearray.writeShort(0x1234);
callCompress(bytearray,"bytearray of shorts with EOFs at various offsets");
for ( var i=0 ; i < 2 ; i++ ) {
var v;
expectEOF("ByteArray readShort_3 #1 " + offset + " " + (i+1),
(function () {
bytearray.position = offset + i + 1;
v = bytearray.readShort();
}));
}
}
for ( var offs=0 ; offs < 4 ; offs++ ) {
readShort_tests1("bigEndian", offs);
readShort_tests1("littleEndian", offs);
readShort_tests2(offs);
readShort_tests3(offs);
}
}
testShortWithLzma();
function testUnsignedShortWithLzma()
{
// One endianness or the other
function readUShort_tests1(endian, offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = endian;
bytearray.position=offset;
bytearray.writeShort(100);
bytearray.writeShort(uint(-200) & 65535);
callCompress(bytearray,"unsigned short");
bytearray.position=offset;
Assert.expectEq("ByteArray readUShort_1 #1 " + endian,
uint(100),
bytearray.readUnsignedShort());
Assert.expectEq("ByteArray readUShort_1 #2 " + endian,
uint(-200) & 65535,
bytearray.readUnsignedShort());
Assert.expectEq("ByteArray readUShort_1 #3" + endian,
4+offset,
bytearray.position);
}
// Mixed endianness: write with one, read with the other
function readUShort_tests2(offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = "bigEndian";
bytearray.position=offset;
bytearray.writeShort(uint(0x1234));
bytearray.writeShort(uint(0xFEDC) & 65535);
callCompress(bytearray,"unsigned short mixed endianness");
bytearray.position=offset;
bytearray.endian = "littleEndian";
Assert.expectEq("ByteArray readUShort_2 #1",
uint(0x3412),
bytearray.readUnsignedShort());
Assert.expectEq("ByteArray readUShort_2 #2",
uint(0xDCFE),
bytearray.readUnsignedShort());
Assert.expectEq("ByteArray readUShort_2 #3",
4+offset,
bytearray.position);
}
// EOF at various offsets and alignments
function readUShort_tests3(offset)
{
var bytearray:ByteArray=makeByteArray(offset); // use offset to create the alignment
bytearray.writeShort(0x1234);
callCompress(bytearray,"unsigned short eof at various offsets");
for ( var i=0 ; i < 2 ; i++ ) {
var v;
expectEOF("ByteArray readUShort_3 #1 " + offset + " " + (i+1),
(function () {
bytearray.position = offset + i + 1;
v = bytearray.readUnsignedShort();
}));
}
}
for ( var offs=0 ; offs < 4 ; offs++ ) {
readUShort_tests1("bigEndian", offs);
readUShort_tests1("littleEndian", offs);
readUShort_tests2(offs);
readUShort_tests3(offs);
}
}
testUnsignedShortWithLzma();
function testIntWithLzma()
{
// One endianness or the other
function readInt_tests1(endian, offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = endian;
bytearray.position=offset;
bytearray.writeInt(100);
bytearray.writeInt(-200);
callCompress(bytearray,"int endianness");
bytearray.position=offset;
Assert.expectEq("ByteArray readInt_1 #1 " + endian,
100,
bytearray.readInt());
Assert.expectEq( "ByteArray readInt_1 #2 " + endian,
-200,
bytearray.readInt());
Assert.expectEq("ByteArray readInt_1 #3" + endian,
8+offset,
bytearray.position);
}
// Mixed endianness: write with one, read with the other
function readInt_tests2(offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = "bigEndian";
bytearray.position=offset;
bytearray.writeInt(int(0x12345678));
bytearray.writeInt(int(0xFEDCBA98));
callCompress(bytearray,"int mixed endianness");
bytearray.position=offset;
bytearray.endian = "littleEndian";
Assert.expectEq("ByteArray readInt_2 #1",
int(0x78563412),
bytearray.readInt());
Assert.expectEq("ByteArray readInt_2 #2",
int(0x98BADCFE),
bytearray.readInt());
Assert.expectEq("ByteArray readInt_2 #3",
8+offset,
bytearray.position);
}
for ( var offs=0 ; offs < 4 ; offs++ ) {
readInt_tests1("bigEndian", offs);
readInt_tests1("littleEndian", offs);
readInt_tests2(offs);
}
}
testIntWithLzma();
function testFloatWithLzma()
{
// One endianness or the other
function readFloat_tests1(endian, offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = endian;
bytearray.position=offset;
bytearray.writeFloat(1.25);
bytearray.writeFloat(12345.5);
callCompress(bytearray,"float");
Assert.expectEq("ByteArray writeFloat_1 #1 " + endian,
8+offset,
bytearray.position);
bytearray.position=offset;
Assert.expectEq("ByteArray readFloat_1 #1 " + endian,
1.25,
bytearray.readFloat());
Assert.expectEq("ByteArray readFloat_1 #2 " + endian,
12345.5,
bytearray.readFloat());
Assert.expectEq("ByteArray readFloat_1 #3" + endian,
8+offset,
bytearray.position);
}
// Mixed endianness: write with one, read with the other.
function readFloat_tests2(offset)
{
var bytearray:ByteArray=makeByteArray(offset);
var temp:ByteArray=new ByteArray();
bytearray.endian = "bigEndian";
bytearray.position=offset;
bytearray.writeFloat(1.25); // write big
bytearray.writeFloat(12345.5); // endian
callCompress(bytearray,"float mixed endianness");
bytearray.endian = "littleEndian";
bytearray.position=offset;
temp.endian = "littleEndian";
temp.writeFloat(bytearray.readFloat()); // read little endian
temp.writeFloat(bytearray.readFloat()); // and write little endian
temp.position = 0;
temp.endian = "bigEndian";
Assert.expectEq("ByteArray readFloat_2 #1",
1.25,
temp.readFloat()); // read big endian
Assert.expectEq("ByteArray readFloat_2 #2",
12345.5,
temp.readFloat());
}
for ( var offs=0 ; offs < 4 ; offs++ ) {
readFloat_tests1("bigEndian", offs);
readFloat_tests1("littleEndian", offs);
readFloat_tests2(offs);
}
}
testFloatWithLzma();
function testDoubleWithLzma()
{
// One endianness or the other
function readDouble_tests1(endian, offset)
{
var bytearray:ByteArray=makeByteArray(offset);
bytearray.endian = endian;
bytearray.position=offset;
bytearray.writeDouble(1.25);
bytearray.writeDouble(12345.5);
callCompress(bytearray,"double");
Assert.expectEq("ByteArray writeDouble_1 #1 " + endian,
16+offset,
bytearray.position);
bytearray.position=offset;
Assert.expectEq("ByteArray readDouble_1 #1 " + endian,
1.25,
bytearray.readDouble());
Assert.expectEq("ByteArray readDouble_1 #2 " + endian,
12345.5,
bytearray.readDouble());
Assert.expectEq("ByteArray readDouble_1 #3" + endian,
16+offset,
bytearray.position);
}
// Mixed endianness: write with one, read with the other.
function readDouble_tests2(offset)
{
var bytearray:ByteArray=makeByteArray(offset);
var temp:ByteArray=new ByteArray;
bytearray.endian = "bigEndian";
bytearray.position=offset;
bytearray.writeDouble(1.25); // write big
bytearray.writeDouble(12345.5); // endian
callCompress(bytearray,"double mixed endianness");
bytearray.endian = "littleEndian";
bytearray.position=offset;
temp.endian = "littleEndian";
temp.writeDouble(bytearray.readDouble()); // read little endian
temp.writeDouble(bytearray.readDouble()); // and write little endian
temp.position = 0;
temp.endian = "bigEndian";
Assert.expectEq("ByteArray readDouble_2 #1",
1.25,
temp.readDouble()); // read big endian
Assert.expectEq("ByteArray readDouble_2 #2",
12345.5,
temp.readDouble());
}
for ( var offs=0 ; offs < 4 ; offs++ ) {
readDouble_tests1("bigEndian", offs);
readDouble_tests1("littleEndian", offs);
readDouble_tests2(offs);
}
}
testDoubleWithLzma();
function testByteWithLzma()
{
var bytearray:ByteArray = makeByteArray();
bytearray.position=0;
bytearray.writeByte(-257);
bytearray.writeByte(37);
callCompress(bytearray,"byte");
Assert.expectEq("testByte: ByteArray position",
2,
bytearray.position);
Assert.expectEq("testByte: ByteArray length",
2,
bytearray.length);
bytearray.position=0;
Assert.expectEq( "ByteArray readByte",
-1,
bytearray.readByte());
Assert.expectEq( "ByteArray readByte",
37,
bytearray.readByte());
var v;
expectEOF("ByteArray readByte EOF",
(function () {
bytearray.position = bytearray.length;
v = bytearray.readByte();
}));
}
testByteWithLzma();
function testUtfWithLzma()
{
var bytearray:ByteArray = makeByteArray();
bytearray.position=0;
bytearray.writeUTF("string");
callCompress(bytearray,"UTF");
Assert.expectEq(
"ByteArray position of utf string",
8,
bytearray.position);
bytearray.position=0;
Assert.expectEq(
"ByteArray length of utf string",
8,
bytearray.length);
Assert.expectEq(
"ByteArray readUTF",
"string",
bytearray.readUTF());
// Also see the readUTFBytes case below.
//
// This is arguably a bug but it's how it currently behaves (Bugzilla 687341).
// readUTF will return a string consisting of the characters up to and not including
// the NUL, but the position will be updated as if the entire string were consumed.
bytearray.length = 0;
bytearray.position = 0;
bytearray.endian = "bigEndian";
bytearray.writeByte(0);
bytearray.writeByte(4);
bytearray.writeByte(108);
bytearray.writeByte(97);
bytearray.writeByte(0);
bytearray.writeByte(115);
callCompress(bytearray,"bytes");
bytearray.position = 0;
Assert.expectEq("ByteArray readUTF on contents containing NUL: contents",
"la",
bytearray.readUTF());
Assert.expectEq("ByteArray readUTF on contents containing NUL: position",
6,
bytearray.position);
// Test EOF in data area
expectEOF("ReadUTF EOF in content",
(function () {
bytearray.length = 0;
bytearray.endian = "bigEndian";
bytearray.writeUTF("super");
bytearray[1] = 6; // One too much
bytearray.position = 0;
bytearray.readUTF();
}));
// Test EOF in length area
expectEOF("ReadUTF EOF in length, #1",
(function () {
bytearray.length = 0;
bytearray.readUTF();
}));
expectEOF("ReadUTF EOF in length, #2",
(function () {
bytearray.length = 0;
bytearray.writeByte(0);
bytearray.position = 0;
bytearray.readUTF();
}));
// Doc sez: A RangeError will be thrown for writeUTF if the string length exceeds 65535.
expectRangeError("RangeError in writeUTF",
(function () {
var s = "86868686";
while (s.length <= 65535)
s = s + s;
bytearray.writeUTF(s);
}));
// Skip UTF-8 BOM.
// This seems fairly ill-defined and ad-hoc since the BOM is skipped but is accounted for in the byte count,
// but it's what we do, so test that we continue to do it...
bytearray.length = 0;
bytearray.position = 0;
bytearray.endian = "bigEndian";
bytearray.writeByte(0);
bytearray.writeByte(6);
bytearray.writeByte(0xEF);
bytearray.writeByte(0xBB);
bytearray.writeByte(0xBF);
bytearray.writeUTFBytes("string");
callCompress(bytearray,"skip UTF-8 BOM");
bytearray.position = 0;
Assert.expectEq("ByteArray readUTF skips UTF8 BOM after length bytes but includes it in the length",
"str",
bytearray.readUTF());
// TODO: test invalid UTF - we should still get data, in a predictable way (invalid input turns into individual bytes)
}
testUtfWithLzma();
function testUtfBytesWithLzma()
{
var bytearray:ByteArray = makeByteArray();
bytearray.position=0;
bytearray.writeUTFBytes("string");
callCompress(bytearray,"UTF bytes");
bytearray.position=0;
Assert.expectEq(
"ByteArray length of utf bytes string",
6,
bytearray.length);
Assert.expectEq(
"ByteArray readUTFBytes",
"string",
bytearray.readUTFBytes(6));
// Also see the readUTF case above.
//
// This is arguably a bug but it's how it currently behaves (Bugzilla 687341).
// readUTF will return a string consisting of the characters up to and not including
// the NUL, but the position will be updated as if the entire string were consumed.
bytearray.length = 0;
bytearray.position = 0;
bytearray.endian = "bigEndian";
bytearray.writeByte(108);
bytearray.writeByte(97);
bytearray.writeByte(0);
bytearray.writeByte(115);
callCompress(bytearray,"bytes contains NULL");
bytearray.position = 0;
Assert.expectEq("ByteArray readUTFBytes on contents containing NUL: contents",
"la",
bytearray.readUTFBytes(4));
Assert.expectEq("ByteArray readUTFBytes on contents containing NUL: position",
4,
bytearray.position);
// Test EOF in data area
expectEOF("ReadUTFBytes EOF in content",
(function () {
bytearray.length = 0;
bytearray.endian = "bigEndian";
bytearray.writeUTF("super");
bytearray.position = 2;
bytearray.readUTFBytes(6); // one too much
}));
// Skip UTF-8 BOM.
// This seems fairly ill-defined and ad-hoc since the BOM is skipped but is accounted for in the byte count,
// but it's what we do, so test that we continue to do it...
bytearray.length = 0;
bytearray.position = 0;
bytearray.endian = "bigEndian";
bytearray.writeByte(0xEF);
bytearray.writeByte(0xBB);
bytearray.writeByte(0xBF);
bytearray.writeUTFBytes("string");
callCompress(bytearray,"bytes contain high value bytes");
bytearray.position = 0;
Assert.expectEq("ByteArray readUTFBytes skips UTF8 BOM but includes it in the length",
"str",
bytearray.readUTFBytes(6));
// TODO: test invalid UTF - we should still get data, in a predictable way (invalid input turns into individual bytes)
}
testUtfBytesWithLzma();
function testBracketSyntaxWithLzma() {
var bytearray:ByteArray = makeByteArray();
bytearray.position=0;
bytearray.writeByte(10);
bytearray.writeByte(11);
bytearray.writeByte(12);
callCompress(bytearray,"bracket syntax");
bytearray.position = 0;
Assert.expectEq(
"ByteArray get [] syntax",
12,
bytearray[2]);
bytearray[2]=13;
Assert.expectEq(
"ByteArray set [] syntax",
13,
bytearray[2]);
}
testBracketSyntaxWithLzma();
function testBOMWithLzma() {
// compress/uncompress with BOM
var bytearray_compress:ByteArray = new ByteArray();
bytearray_compress[0]=0xef;
bytearray_compress[1]=0xbb;
bytearray_compress[2]=0xbf;
bytearray_compress[3]=100;
bytearray_compress[4]=97;
bytearray_compress[5]=110;
bytearray_compress[6]=33;
// original length = 7
var origlength=bytearray_compress.length;
bytearray_compress.compress("lzma");
// test the compressed bytearray values are all different from the original
var compressstate=(bytearray_compress[0]==0xef ||
bytearray_compress[1]==0xbb ||
bytearray_compress[2]==0xbf ||
bytearray_compress[3]==100 ||
bytearray_compress[4]==97);
// check the compressed length = 15 (small strings compress larger in zlib)
var compresslength=bytearray_compress.length;
bytearray_compress.uncompress("lzma");
// check the uncompress/compress length should equal original length 7
var restoredlength=bytearray_compress.length;
var restorestate=(bytearray_compress[0]==0xef &&
bytearray_compress[1]==0xbb &&
bytearray_compress[2]==0xbf &&
bytearray_compress[3]==100 &&
bytearray_compress[4]==97 &&
bytearray_compress[5]==110 &&
bytearray_compress[6]==33
);
Assert.expectEq("ByteArray.compress bytearray length is different",
origlength==compresslength,false);
Assert.expectEq("ByteArray.compress bytearray contents differ",
compressstate,false);
Assert.expectEq("ByteArray.uncompress bytearray length matches before compress",
origlength,restoredlength);
Assert.expectEq("ByteArray.uncompress uncompressing compressed string matches original",
restorestate,true);
}
testBOMWithLzma();
// lzma-compressed data format:
// 5 bytes: LZMA properties
// 8 bytes: uncompressed size k (little-endian)
// k bytes: payload (the compressed data)
function testIllFormedLzmaLowSize():void {
var b1:ByteArray = new ByteArray();
b1.writeUTF("string");
b1.compress(CompressionAlgorithm.LZMA);
var b2:ByteArray = new ByteArray();
// muck with low 32 bits of size
for (var i:uint=0; i < 4; i++) {
b2.clear();
b1.position = 0;
b1.readBytes(b2);
b2[5 + i] += 1;
var result;
try {
b2.uncompress(CompressionAlgorithm.LZMA);
result = "unexpected"
} catch (e:IOError) {
result = "ioerror on wrong size"
}
Assert.expectEq("ByteArray.uncompress ill-formed LZMA size "+i+" byte",
"ioerror on wrong size",result);
}
}
// comment out test due to bug: https://bugzilla.mozilla.org/show_bug.cgi?id=778727
//testIllFormedLzmaLowSize();
function testIllFormedLzmaHighSize():void {
var b1:ByteArray = new ByteArray();
b1.writeUTF("string");
b1.compress(CompressionAlgorithm.LZMA);
var b2:ByteArray = new ByteArray();
// muck with high 32 bits of size
for (var i:uint=4; i < 8; i++) {
b2.clear();
b1.position = 0;
b1.readBytes(b2);
b2[5 + i] += 1;
var result;
try {
b2.uncompress(CompressionAlgorithm.LZMA);
result = "unexpected"
} catch (e:MemoryError) {
result = "memoryerror on huge size"
}
Assert.expectEq("ByteArray.uncompress ill-formed LZMA size "+i+" byte",
"memoryerror on huge size",result);
}
}
// comment out test due to bug: https://bugzilla.mozilla.org/show_bug.cgi?id=778727
// testIllFormedLzmaHighSize();
// (Below is not necessarily working; in particular Felix would have expected
// it to hit the IllFormedLzma cases above, but for some reason it is not.)
function testFuzzedLzma():void {
var b1:ByteArray = new ByteArray();
b1.writeUTF("string");
b1.compress(CompressionAlgorithm.LZMA);
var b2:ByteArray = new ByteArray();
var errors:String="";
for (var i:uint=0; i < b1.length * 8; i++) {
b2.clear();
b1.position = 0;
// print("b1.length A: "+b1.length);
b1.readBytes(b2);
// print("b1.length B: "+b1.length);
var byteOffset:uint = i / 8;
var bitOffset:uint = i % 8;
var oldByte:uint = b2[byteOffset];
var oldBit:uint = (oldByte >> bitOffset) & 0x1;
var newByte:uint = (oldByte ^ (oldBit << bitOffset)) & 0xFF;
b2[byteOffset] = newByte;
// print('b1 ['+Array.prototype.join.call(b1, ',')+']');
// print('b2 ['+Array.prototype.join.call(b2, ',')+']');
var result;
// This test is largely fishing for segfaults (and striving for code coverage)
try {
b2.uncompress(CompressionAlgorithm.LZMA);
// If we get here, then the LZMA algorithm completed and
// we have no idea what the resulting byte array contains.
result = "expected" // no exn
} catch (e:MemoryError) {
result = "expected"
} catch (e:IOError) {
// should also verify that original data was restored
result = "expected"
}
if (result!="expected") {
errors+=" error fuzzing bit "+i+" ";
}
}
Assert.expectEq("ByteArray.uncompress fuzzed LZMA input check for errors",
"",errors);
}
// Commenting out test because it is not behaving the way Felix would
// expect and he does not want to take the time now to debug it.
// comment out test due to bug: https://bugzilla.mozilla.org/show_bug.cgi?id=778727
// testFuzzedLzma();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,397 @@
empty bytearray: expecting no exception PASSED!
empty bytearray: expecting length no change PASSED!
zero length bytearray: expecting no exception PASSED!
zero length bytearray: expecting length no change PASSED!
expecting thrown exception PASSED!
expecting thrown exception compressWithZlibUncompressLzma PASSED!
expecting thrown exception uncompressWithZlibUncompressLzma PASSED!
uncompressWithoutCompressionLzma bytearray length matches before uncompress PASSED!
ByteArray position after writing Booleans PASSED!
boolean bytearray: expecting no exception PASSED!
boolean bytearray: expecting length no change PASSED!
ByteArray move position to 0 PASSED!
ByteArray write/read boolean true PASSED!
ByteArray write/read boolean false PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
bytearray of short mixed endianness: expecting no exception PASSED!
bytearray of short mixed endianness: expecting length no change PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
bytearray of shorts with EOFs at various offsets: expecting no exception PASSED!
bytearray of shorts with EOFs at various offsets: expecting length no change PASSED!
ByteArray readShort_3 #1 0 1 PASSED!
ByteArray readShort_3 #1 0 2 PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
bytearray of short mixed endianness: expecting no exception PASSED!
bytearray of short mixed endianness: expecting length no change PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
bytearray of shorts with EOFs at various offsets: expecting no exception PASSED!
bytearray of shorts with EOFs at various offsets: expecting length no change PASSED!
ByteArray readShort_3 #1 1 1 PASSED!
ByteArray readShort_3 #1 1 2 PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
bytearray of short mixed endianness: expecting no exception PASSED!
bytearray of short mixed endianness: expecting length no change PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
bytearray of shorts with EOFs at various offsets: expecting no exception PASSED!
bytearray of shorts with EOFs at various offsets: expecting length no change PASSED!
ByteArray readShort_3 #1 2 1 PASSED!
ByteArray readShort_3 #1 2 2 PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 bigEndian PASSED!
ByteArray readShort_1 #2 bigEndian PASSED!
ByteArray readShort_1 #3bigEndian PASSED!
bytearray of short: expecting no exception PASSED!
bytearray of short: expecting length no change PASSED!
ByteArray readShort_1 #1 littleEndian PASSED!
ByteArray readShort_1 #2 littleEndian PASSED!
ByteArray readShort_1 #3littleEndian PASSED!
bytearray of short mixed endianness: expecting no exception PASSED!
bytearray of short mixed endianness: expecting length no change PASSED!
ByteArray readShort_2 #1 PASSED!
ByteArray readShort_2 #2 PASSED!
ByteArray readShort_2 #3 PASSED!
bytearray of shorts with EOFs at various offsets: expecting no exception PASSED!
bytearray of shorts with EOFs at various offsets: expecting length no change PASSED!
ByteArray readShort_3 #1 3 1 PASSED!
ByteArray readShort_3 #1 3 2 PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
unsigned short mixed endianness: expecting no exception PASSED!
unsigned short mixed endianness: expecting length no change PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
unsigned short eof at various offsets: expecting no exception PASSED!
unsigned short eof at various offsets: expecting length no change PASSED!
ByteArray readUShort_3 #1 0 1 PASSED!
ByteArray readUShort_3 #1 0 2 PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
unsigned short mixed endianness: expecting no exception PASSED!
unsigned short mixed endianness: expecting length no change PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
unsigned short eof at various offsets: expecting no exception PASSED!
unsigned short eof at various offsets: expecting length no change PASSED!
ByteArray readUShort_3 #1 1 1 PASSED!
ByteArray readUShort_3 #1 1 2 PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
unsigned short mixed endianness: expecting no exception PASSED!
unsigned short mixed endianness: expecting length no change PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
unsigned short eof at various offsets: expecting no exception PASSED!
unsigned short eof at various offsets: expecting length no change PASSED!
ByteArray readUShort_3 #1 2 1 PASSED!
ByteArray readUShort_3 #1 2 2 PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 bigEndian PASSED!
ByteArray readUShort_1 #2 bigEndian PASSED!
ByteArray readUShort_1 #3bigEndian PASSED!
unsigned short: expecting no exception PASSED!
unsigned short: expecting length no change PASSED!
ByteArray readUShort_1 #1 littleEndian PASSED!
ByteArray readUShort_1 #2 littleEndian PASSED!
ByteArray readUShort_1 #3littleEndian PASSED!
unsigned short mixed endianness: expecting no exception PASSED!
unsigned short mixed endianness: expecting length no change PASSED!
ByteArray readUShort_2 #1 PASSED!
ByteArray readUShort_2 #2 PASSED!
ByteArray readUShort_2 #3 PASSED!
unsigned short eof at various offsets: expecting no exception PASSED!
unsigned short eof at various offsets: expecting length no change PASSED!
ByteArray readUShort_3 #1 3 1 PASSED!
ByteArray readUShort_3 #1 3 2 PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
int mixed endianness: expecting no exception PASSED!
int mixed endianness: expecting length no change PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
int mixed endianness: expecting no exception PASSED!
int mixed endianness: expecting length no change PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
int mixed endianness: expecting no exception PASSED!
int mixed endianness: expecting length no change PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 bigEndian PASSED!
ByteArray readInt_1 #2 bigEndian PASSED!
ByteArray readInt_1 #3bigEndian PASSED!
int endianness: expecting no exception PASSED!
int endianness: expecting length no change PASSED!
ByteArray readInt_1 #1 littleEndian PASSED!
ByteArray readInt_1 #2 littleEndian PASSED!
ByteArray readInt_1 #3littleEndian PASSED!
int mixed endianness: expecting no exception PASSED!
int mixed endianness: expecting length no change PASSED!
ByteArray readInt_2 #1 PASSED!
ByteArray readInt_2 #2 PASSED!
ByteArray readInt_2 #3 PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
float mixed endianness: expecting no exception PASSED!
float mixed endianness: expecting length no change PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
float mixed endianness: expecting no exception PASSED!
float mixed endianness: expecting length no change PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
float mixed endianness: expecting no exception PASSED!
float mixed endianness: expecting length no change PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #1 bigEndian PASSED!
ByteArray readFloat_1 #2 bigEndian PASSED!
ByteArray readFloat_1 #3bigEndian PASSED!
float: expecting no exception PASSED!
float: expecting length no change PASSED!
ByteArray writeFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #1 littleEndian PASSED!
ByteArray readFloat_1 #2 littleEndian PASSED!
ByteArray readFloat_1 #3littleEndian PASSED!
float mixed endianness: expecting no exception PASSED!
float mixed endianness: expecting length no change PASSED!
ByteArray readFloat_2 #1 PASSED!
ByteArray readFloat_2 #2 PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
double mixed endianness: expecting no exception PASSED!
double mixed endianness: expecting length no change PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
double mixed endianness: expecting no exception PASSED!
double mixed endianness: expecting length no change PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
double mixed endianness: expecting no exception PASSED!
double mixed endianness: expecting length no change PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #1 bigEndian PASSED!
ByteArray readDouble_1 #2 bigEndian PASSED!
ByteArray readDouble_1 #3bigEndian PASSED!
double: expecting no exception PASSED!
double: expecting length no change PASSED!
ByteArray writeDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #1 littleEndian PASSED!
ByteArray readDouble_1 #2 littleEndian PASSED!
ByteArray readDouble_1 #3littleEndian PASSED!
double mixed endianness: expecting no exception PASSED!
double mixed endianness: expecting length no change PASSED!
ByteArray readDouble_2 #1 PASSED!
ByteArray readDouble_2 #2 PASSED!
byte: expecting no exception PASSED!
byte: expecting length no change PASSED!
testByte: ByteArray position PASSED!
testByte: ByteArray length PASSED!
ByteArray readByte PASSED!
ByteArray readByte PASSED!
ByteArray readByte EOF PASSED!
UTF: expecting no exception PASSED!
UTF: expecting length no change PASSED!
ByteArray position of utf string PASSED!
ByteArray length of utf string PASSED!
ByteArray readUTF PASSED!
bytes: expecting no exception PASSED!
bytes: expecting length no change PASSED!
ByteArray readUTF on contents containing NUL: contents PASSED!
ByteArray readUTF on contents containing NUL: position PASSED!
ReadUTF EOF in content PASSED!
ReadUTF EOF in length, #1 PASSED!
ReadUTF EOF in length, #2 PASSED!
RangeError in writeUTF PASSED!
skip UTF-8 BOM: expecting no exception PASSED!
skip UTF-8 BOM: expecting length no change PASSED!
ByteArray readUTF skips UTF8 BOM after length bytes but includes it in the length PASSED!
UTF bytes: expecting no exception PASSED!
UTF bytes: expecting length no change PASSED!
ByteArray length of utf bytes string PASSED!
ByteArray readUTFBytes PASSED!
bytes contains NULL: expecting no exception PASSED!
bytes contains NULL: expecting length no change PASSED!
ByteArray readUTFBytes on contents containing NUL: contents PASSED!
ByteArray readUTFBytes on contents containing NUL: position PASSED!
ReadUTFBytes EOF in content PASSED!
bytes contain high value bytes: expecting no exception PASSED!
bytes contain high value bytes: expecting length no change PASSED!
ByteArray readUTFBytes skips UTF8 BOM but includes it in the length PASSED!
bracket syntax: expecting no exception PASSED!
bracket syntax: expecting length no change PASSED!
ByteArray get [] syntax PASSED!
ByteArray set [] syntax PASSED!
ByteArray.compress bytearray length is different PASSED!
ByteArray.compress bytearray contents differ PASSED!
ByteArray.uncompress bytearray length matches before compress PASSED!
ByteArray.uncompress uncompressing compressed string matches original PASSED!

View File

@ -0,0 +1,5 @@
num_ticks = 1
known_failure = true
[required_features]
lzma = true

View File

@ -0,0 +1,356 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
/* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// General principles for this test suite:
//
// - never write just one, write at least two (to test that position
// advances correctly and output is placed correctly)
// - ditto read
// - test both little and big endian for multibyte data
// - test both aligned and unaligned access for multibyte data
//
// Search for "TODO" for comments about missing tests.
package {
import flash.display.MovieClip;
public class Test extends MovieClip {}
}
import flash.errors.EOFError;
import flash.errors.IOError;
import flash.utils.ByteArray;
import flash.utils.ByteArray;
import flash.utils.ByteArray;
import flash.utils.CompressionAlgorithm;
import com.adobe.test.Assert;
// var SECTION = "ByteArrayWithLzmaThirdParty";
// var VERSION = "as3";
// var TITLE = "test ByteArray class with lzma inputs generated via LZMA.jar";
var abc_compressed_hello = new ByteArray();
abc_compressed_hello.writeByte(0x5D);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x80);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x92);
abc_compressed_hello.writeByte(0x01);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x24);
abc_compressed_hello.writeByte(0x19);
abc_compressed_hello.writeByte(0x49);
abc_compressed_hello.writeByte(0x98);
abc_compressed_hello.writeByte(0x6F);
abc_compressed_hello.writeByte(0x10);
abc_compressed_hello.writeByte(0x11);
abc_compressed_hello.writeByte(0xC8);
abc_compressed_hello.writeByte(0x5F);
abc_compressed_hello.writeByte(0xE6);
abc_compressed_hello.writeByte(0xD5);
abc_compressed_hello.writeByte(0x8A);
abc_compressed_hello.writeByte(0x64);
abc_compressed_hello.writeByte(0x72);
abc_compressed_hello.writeByte(0x70);
abc_compressed_hello.writeByte(0x9E);
abc_compressed_hello.writeByte(0xA8);
abc_compressed_hello.writeByte(0x41);
abc_compressed_hello.writeByte(0x82);
abc_compressed_hello.writeByte(0x52);
abc_compressed_hello.writeByte(0x13);
abc_compressed_hello.writeByte(0x1B);
abc_compressed_hello.writeByte(0x09);
abc_compressed_hello.writeByte(0xB2);
abc_compressed_hello.writeByte(0x30);
abc_compressed_hello.writeByte(0x51);
abc_compressed_hello.writeByte(0xAD);
abc_compressed_hello.writeByte(0x62);
abc_compressed_hello.writeByte(0x82);
abc_compressed_hello.writeByte(0xA4);
abc_compressed_hello.writeByte(0x1B);
abc_compressed_hello.writeByte(0x14);
abc_compressed_hello.writeByte(0x99);
abc_compressed_hello.writeByte(0xF4);
abc_compressed_hello.writeByte(0xBB);
abc_compressed_hello.writeByte(0xCB);
abc_compressed_hello.writeByte(0x46);
abc_compressed_hello.writeByte(0xF9);
abc_compressed_hello.writeByte(0x2F);
abc_compressed_hello.writeByte(0x5D);
abc_compressed_hello.writeByte(0x05);
abc_compressed_hello.writeByte(0x6F);
abc_compressed_hello.writeByte(0xA1);
abc_compressed_hello.writeByte(0xA0);
abc_compressed_hello.writeByte(0x46);
abc_compressed_hello.writeByte(0xB7);
abc_compressed_hello.writeByte(0x9D);
abc_compressed_hello.writeByte(0x4C);
abc_compressed_hello.writeByte(0x1A);
abc_compressed_hello.writeByte(0x7F);
abc_compressed_hello.writeByte(0xB4);
abc_compressed_hello.writeByte(0xD4);
abc_compressed_hello.writeByte(0xFC);
abc_compressed_hello.writeByte(0x7C);
abc_compressed_hello.writeByte(0x4B);
abc_compressed_hello.writeByte(0x83);
abc_compressed_hello.writeByte(0x84);
abc_compressed_hello.writeByte(0x97);
abc_compressed_hello.writeByte(0x7C);
abc_compressed_hello.writeByte(0x25);
abc_compressed_hello.writeByte(0xCB);
abc_compressed_hello.writeByte(0x0E);
abc_compressed_hello.writeByte(0xA4);
abc_compressed_hello.writeByte(0xEB);
abc_compressed_hello.writeByte(0x5C);
abc_compressed_hello.writeByte(0xD5);
abc_compressed_hello.writeByte(0x69);
abc_compressed_hello.writeByte(0x91);
abc_compressed_hello.writeByte(0xE0);
abc_compressed_hello.writeByte(0xE3);
abc_compressed_hello.writeByte(0x1B);
abc_compressed_hello.writeByte(0xD9);
abc_compressed_hello.writeByte(0x8A);
abc_compressed_hello.writeByte(0x7F);
abc_compressed_hello.writeByte(0x63);
abc_compressed_hello.writeByte(0x44);
abc_compressed_hello.writeByte(0xB7);
abc_compressed_hello.writeByte(0x89);
abc_compressed_hello.writeByte(0x36);
abc_compressed_hello.writeByte(0x82);
abc_compressed_hello.writeByte(0x68);
abc_compressed_hello.writeByte(0x6F);
abc_compressed_hello.writeByte(0xBD);
abc_compressed_hello.writeByte(0x1C);
abc_compressed_hello.writeByte(0x3F);
abc_compressed_hello.writeByte(0x1F);
abc_compressed_hello.writeByte(0xE5);
abc_compressed_hello.writeByte(0xC1);
abc_compressed_hello.writeByte(0xF9);
abc_compressed_hello.writeByte(0xE5);
abc_compressed_hello.writeByte(0x36);
abc_compressed_hello.writeByte(0xB4);
abc_compressed_hello.writeByte(0x08);
abc_compressed_hello.writeByte(0x71);
abc_compressed_hello.writeByte(0x14);
abc_compressed_hello.writeByte(0xAC);
abc_compressed_hello.writeByte(0x9E);
abc_compressed_hello.writeByte(0xEC);
abc_compressed_hello.writeByte(0x24);
abc_compressed_hello.writeByte(0x82);
abc_compressed_hello.writeByte(0x77);
abc_compressed_hello.writeByte(0x5E);
abc_compressed_hello.writeByte(0x68);
abc_compressed_hello.writeByte(0x00);
abc_compressed_hello.writeByte(0x23);
abc_compressed_hello.writeByte(0x75);
abc_compressed_hello.writeByte(0x68);
abc_compressed_hello.writeByte(0xEE);
abc_compressed_hello.writeByte(0x03);
abc_compressed_hello.writeByte(0x9A);
abc_compressed_hello.writeByte(0x62);
abc_compressed_hello.writeByte(0x2D);
abc_compressed_hello.writeByte(0xFE);
abc_compressed_hello.writeByte(0xA0);
abc_compressed_hello.writeByte(0x72);
abc_compressed_hello.writeByte(0x13);
abc_compressed_hello.writeByte(0x80);
abc_compressed_hello.writeByte(0x58);
abc_compressed_hello.writeByte(0x8B);
abc_compressed_hello.writeByte(0x79);
abc_compressed_hello.writeByte(0x63);
abc_compressed_hello.writeByte(0x6E);
abc_compressed_hello.writeByte(0x14);
abc_compressed_hello.writeByte(0xF3);
abc_compressed_hello.writeByte(0x72);
abc_compressed_hello.writeByte(0x70);
abc_compressed_hello.writeByte(0x4F);
abc_compressed_hello.writeByte(0xFD);
abc_compressed_hello.writeByte(0x81);
abc_compressed_hello.writeByte(0xCA);
abc_compressed_hello.writeByte(0x3D);
abc_compressed_hello.writeByte(0xD5);
abc_compressed_hello.writeByte(0xB6);
abc_compressed_hello.writeByte(0x6F);
abc_compressed_hello.writeByte(0xD2);
abc_compressed_hello.writeByte(0xAF);
abc_compressed_hello.writeByte(0x79);
abc_compressed_hello.writeByte(0x09);
abc_compressed_hello.writeByte(0xE5);
abc_compressed_hello.writeByte(0x27);
abc_compressed_hello.writeByte(0x03);
abc_compressed_hello.writeByte(0x8C);
abc_compressed_hello.writeByte(0x2F);
abc_compressed_hello.writeByte(0x73);
abc_compressed_hello.writeByte(0x29);
abc_compressed_hello.writeByte(0xED);
abc_compressed_hello.writeByte(0xAC);
abc_compressed_hello.writeByte(0xC2);
abc_compressed_hello.writeByte(0xD9);
abc_compressed_hello.writeByte(0xC3);
abc_compressed_hello.writeByte(0x86);
abc_compressed_hello.writeByte(0x27);
abc_compressed_hello.writeByte(0x38);
abc_compressed_hello.writeByte(0x23);
abc_compressed_hello.writeByte(0xDC);
abc_compressed_hello.writeByte(0x84);
abc_compressed_hello.writeByte(0x52);
abc_compressed_hello.writeByte(0xA7);
abc_compressed_hello.writeByte(0x9F);
abc_compressed_hello.writeByte(0xF7);
abc_compressed_hello.writeByte(0x5F);
abc_compressed_hello.writeByte(0xF3);
abc_compressed_hello.writeByte(0x1B);
abc_compressed_hello.writeByte(0x7E);
abc_compressed_hello.writeByte(0x74);
abc_compressed_hello.writeByte(0x57);
abc_compressed_hello.writeByte(0xD6);
abc_compressed_hello.writeByte(0xEB);
abc_compressed_hello.writeByte(0x62);
abc_compressed_hello.writeByte(0xF4);
abc_compressed_hello.writeByte(0x31);
abc_compressed_hello.writeByte(0x3B);
abc_compressed_hello.writeByte(0x11);
abc_compressed_hello.writeByte(0xE5);
abc_compressed_hello.writeByte(0x50);
abc_compressed_hello.writeByte(0x1C);
abc_compressed_hello.writeByte(0x49);
abc_compressed_hello.writeByte(0x10);
abc_compressed_hello.writeByte(0x61);
abc_compressed_hello.writeByte(0xC9);
abc_compressed_hello.writeByte(0x5D);
abc_compressed_hello.writeByte(0x1C);
abc_compressed_hello.writeByte(0x15);
abc_compressed_hello.writeByte(0x45);
abc_compressed_hello.writeByte(0x87);
abc_compressed_hello.writeByte(0x55);
abc_compressed_hello.writeByte(0x10);
abc_compressed_hello.writeByte(0x21);
abc_compressed_hello.writeByte(0x7F);
abc_compressed_hello.writeByte(0x83);
abc_compressed_hello.writeByte(0x1B);
abc_compressed_hello.writeByte(0xFD);
abc_compressed_hello.writeByte(0x8E);
abc_compressed_hello.writeByte(0x4C);
abc_compressed_hello.writeByte(0xD1);
abc_compressed_hello.writeByte(0x9B);
abc_compressed_hello.writeByte(0x27);
abc_compressed_hello.writeByte(0x01);
abc_compressed_hello.writeByte(0x0E);
abc_compressed_hello.writeByte(0x35);
abc_compressed_hello.writeByte(0x34);
abc_compressed_hello.writeByte(0xFB);
abc_compressed_hello.writeByte(0x1D);
abc_compressed_hello.writeByte(0xA7);
abc_compressed_hello.writeByte(0xA1);
abc_compressed_hello.writeByte(0xA9);
abc_compressed_hello.writeByte(0x1A);
abc_compressed_hello.writeByte(0x42);
abc_compressed_hello.writeByte(0xAB);
abc_compressed_hello.writeByte(0x4F);
abc_compressed_hello.writeByte(0xA3);
abc_compressed_hello.writeByte(0x82);
abc_compressed_hello.writeByte(0xA7);
abc_compressed_hello.writeByte(0x37);
abc_compressed_hello.writeByte(0x04);
abc_compressed_hello.writeByte(0x95);
abc_compressed_hello.writeByte(0x1E);
abc_compressed_hello.writeByte(0xF8);
abc_compressed_hello.writeByte(0x8E);
abc_compressed_hello.writeByte(0xA5);
abc_compressed_hello.writeByte(0x0F);
abc_compressed_hello.writeByte(0x9A);
abc_compressed_hello.writeByte(0xE4);
abc_compressed_hello.position = 0;
var abc_compressed_small = new ByteArray();
abc_compressed_small.writeByte(0x5D);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x80);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x1C);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x22);
abc_compressed_small.writeByte(0x19);
abc_compressed_small.writeByte(0x49);
abc_compressed_small.writeByte(0x86);
abc_compressed_small.writeByte(0xB0);
abc_compressed_small.writeByte(0x70);
abc_compressed_small.writeByte(0x8E);
abc_compressed_small.writeByte(0xD1);
abc_compressed_small.writeByte(0xE2);
abc_compressed_small.writeByte(0xA2);
abc_compressed_small.writeByte(0x80);
abc_compressed_small.writeByte(0x2D);
abc_compressed_small.writeByte(0xE1);
abc_compressed_small.writeByte(0x85);
abc_compressed_small.writeByte(0x6F);
abc_compressed_small.writeByte(0x1E);
abc_compressed_small.writeByte(0xE6);
abc_compressed_small.writeByte(0xD5);
abc_compressed_small.writeByte(0x4B);
abc_compressed_small.writeByte(0x2A);
abc_compressed_small.writeByte(0x79);
abc_compressed_small.writeByte(0x6C);
abc_compressed_small.writeByte(0x55);
abc_compressed_small.writeByte(0x20);
abc_compressed_small.writeByte(0x8E);
abc_compressed_small.writeByte(0x60);
abc_compressed_small.writeByte(0x9D);
abc_compressed_small.writeByte(0x9A);
abc_compressed_small.writeByte(0x61);
abc_compressed_small.writeByte(0x26);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.writeByte(0x00);
abc_compressed_small.position = 0;
// Bugzilla 733051: ByteArrayLzma callCompress tests are doing
// round-trips through compress and uncompress; this test is checking
// that we correctly handle inputs that have been compressed by
// third-party utilities (see LZMA.jar attached to Bugzilla 729336).
function testThirdPartyLzmaInputs()
{
var compressedHello:ByteArray = new ByteArray();
compressedHello.writeBytes(abc_compressed_hello);
var compressedSmall:ByteArray = new ByteArray();
compressedSmall.writeBytes(abc_compressed_small);
var helloString:String = "Hello World!\n" +
"\n" +
"More text; Felix wants to illustrate content that is compressed by\n" +
"LZMA, but a 13 byte file with just \"Hello World!\\n\" is compressed to a\n" +
"31 byte file by LZMA. (Though perhaps a large portion is LZMA header?\n" +
"Not sure yet.) Easy ending: LZMA LZMA LZMA Hello World LZMA LZMA LZMA\n" +
"LZMA LZMA LZMA Hello World LZMA LZMA LZMA Malkovich Malkovich LZMA\n" +
"LZMA LZMA Malkovich LZMA LZMA LZMA LZMA.\n";
var smallString:String = "Deliberately small snippet.\n";
compressedHello.uncompress(CompressionAlgorithm.LZMA);
var helloString2:String = compressedHello.readUTFBytes(compressedHello.length);
Assert.expectEq("Correct lzma uncompression on hello", helloString, helloString2);
compressedSmall.uncompress(CompressionAlgorithm.LZMA);
var smallString2:String = compressedSmall.readUTFBytes(compressedSmall.length);
Assert.expectEq("Correct lzma uncompression on small", smallString, smallString2);
}
testThirdPartyLzmaInputs();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,2 @@
Correct lzma uncompression on hello PASSED!
Correct lzma uncompression on small PASSED!

View File

@ -0,0 +1,4 @@
num_ticks = 1
[required_features]
lzma = true