From e719e4ad32de3dc563255d79774d7273e4a769d3 Mon Sep 17 00:00:00 2001 From: honfika Date: Sat, 16 Aug 2014 13:52:01 +0200 Subject: [PATCH] test fixed --- src/com/jpexs/decompiler/flash/abc/ABCInputStream.java | 6 +++++- .../jpexs/decompiler/flash/tags/text/TextLexer.java | 7 ++++++- test/com/jpexs/decompiler/flash/ABCStreamTest.java | 10 +++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java b/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java index bd0914a7f..67bceeb36 100644 --- a/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java +++ b/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java @@ -36,7 +36,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -public class ABCInputStream { +public class ABCInputStream implements AutoCloseable { private static final int CLASS_PROTECTED_NS = 8; private static final int ATTR_METADATA = 4; @@ -476,4 +476,8 @@ public class ABCInputStream { public long getPosition() { return bytesRead; } + + @Override + public void close() { + } } diff --git a/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java b/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java index ed3653c29..fd7ec44bc 100644 --- a/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java +++ b/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java @@ -401,6 +401,7 @@ public final class TextLexer { /** * Closes the input stream. + * @throws java.io.IOException */ public final void yyclose() throws java.io.IOException { zzAtEOF = true; /* indicate end of file */ @@ -435,6 +436,7 @@ public final class TextLexer { /** * Returns the current lexical state. + * @return */ public final int yystate() { return zzLexicalState; @@ -451,6 +453,7 @@ public final class TextLexer { /** * Returns the text matched by the current regular expression. + * @return */ public final String yytext() { return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); @@ -472,6 +475,7 @@ public final class TextLexer { /** * Returns the length of the matched text region. + * @return */ public final int yylength() { return zzMarkedPos - zzStartRead; @@ -523,6 +527,7 @@ public final class TextLexer { * * @return the next token * @exception java.io.IOException if any I/O-Error occurs + * @throws com.jpexs.decompiler.flash.tags.text.ParseException */ public ParsedSymbol yylex() throws java.io.IOException, ParseException { int zzInput; @@ -678,7 +683,7 @@ public final class TextLexer { if (string != null) { String ret = string.toString(); string = null; - return new ParsedSymbol(SymbolType.TEXT, ret.toString()); + return new ParsedSymbol(SymbolType.TEXT, ret); } } case 21: diff --git a/test/com/jpexs/decompiler/flash/ABCStreamTest.java b/test/com/jpexs/decompiler/flash/ABCStreamTest.java index 9815a78b3..343a63b2a 100644 --- a/test/com/jpexs/decompiler/flash/ABCStreamTest.java +++ b/test/com/jpexs/decompiler/flash/ABCStreamTest.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.abc.ABCInputStream; import com.jpexs.decompiler.flash.abc.ABCOutputStream; import com.jpexs.decompiler.flash.gui.Main; -import java.io.ByteArrayInputStream; +import com.jpexs.helpers.MemoryInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import static org.testng.Assert.assertEquals; @@ -45,10 +45,10 @@ public class ABCStreamTest { long number = 1531; aos.writeU30(number); aos.close(); - try (ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ABCInputStream ais = new ABCInputStream(bais);) { - assertEquals(number, ais.readU30()); - assertEquals(0, bais.available()); + try (MemoryInputStream mis = new MemoryInputStream(baos.toByteArray()); + ABCInputStream ais = new ABCInputStream(mis);) { + assertEquals(number, ais.readU30("test")); + assertEquals(0, mis.available()); } } catch (IOException ex) { fail();