Browse Source

[cs] fix FileInput.eof(), add cs to sys tests

Dan Korostelev 10 years ago
parent
commit
795390d415
4 changed files with 21 additions and 4 deletions
  1. 13 4
      std/cs/io/NativeInput.hx
  2. 5 0
      tests/RunCi.hx
  3. 2 0
      tests/sys/compile-cs.hxml
  4. 1 0
      tests/sys/compile.hxml

+ 13 - 4
std/cs/io/NativeInput.hx

@@ -31,16 +31,22 @@ class NativeInput extends Input
 	public var canSeek(get_canSeek, null):Bool;
 	public var canSeek(get_canSeek, null):Bool;
 
 
 	var stream:cs.system.io.Stream;
 	var stream:cs.system.io.Stream;
+	var _eof:Bool;
+
 	public function new(stream)
 	public function new(stream)
 	{
 	{
 		this.stream = stream;
 		this.stream = stream;
+		this._eof = false;
 		if (!stream.CanRead) throw "Write-only stream";
 		if (!stream.CanRead) throw "Write-only stream";
 	}
 	}
 
 
 	override public function readByte():Int
 	override public function readByte():Int
 	{
 	{
 		var ret = stream.ReadByte();
 		var ret = stream.ReadByte();
-		if (ret == -1) throw new Eof();
+		if (ret == -1) {
+			_eof = true;
+			throw new Eof();
+		}
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -49,8 +55,10 @@ class NativeInput extends Input
 		if( pos < 0 || len < 0 || pos + len > s.length )
 		if( pos < 0 || len < 0 || pos + len > s.length )
 			throw Error.OutsideBounds;
 			throw Error.OutsideBounds;
 		var ret = stream.Read(s.getData(), pos, len);
 		var ret = stream.Read(s.getData(), pos, len);
-		if (ret == 0)
+		if (ret == 0) {
+			_eof = true;
 			throw new Eof();
 			throw new Eof();
+		}
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -66,6 +74,7 @@ class NativeInput extends Input
 
 
 	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
 	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
 	{
 	{
+		_eof = false;
 		var pos = switch(pos)
 		var pos = switch(pos)
 		{
 		{
 			case SeekBegin: cs.system.io.SeekOrigin.Begin;
 			case SeekBegin: cs.system.io.SeekOrigin.Begin;
@@ -81,8 +90,8 @@ class NativeInput extends Input
 		return cast(stream.Position, Int);
 		return cast(stream.Position, Int);
 	}
 	}
 
 
-	public function eof() : Bool
+	public inline function eof() : Bool
 	{
 	{
-		return stream.Position == stream.Length;
+		return _eof;
 	}
 	}
 }
 }

+ 5 - 0
tests/RunCi.hx

@@ -563,6 +563,11 @@ class RunCi {
 							runExe("bin/cs_unsafe/bin/Test-Debug.exe");
 							runExe("bin/cs_unsafe/bin/Test-Debug.exe");
 					}
 					}
 
 
+					changeDirectory(sysDir);
+					runCommand("haxe", ["compile-cs.hxml"]);
+					changeDirectory("bin/cs");
+					runCommand("bin/Main-Debug.exe", args);
+
 				case Flash9:
 				case Flash9:
 					setupFlashPlayerDebugger();
 					setupFlashPlayerDebugger();
 					runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb"]);
 					runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb"]);

+ 2 - 0
tests/sys/compile-cs.hxml

@@ -0,0 +1,2 @@
+compile-each.hxml
+-cs bin/cs

+ 1 - 0
tests/sys/compile.hxml

@@ -1,4 +1,5 @@
 --next compile-neko.hxml
 --next compile-neko.hxml
 --next compile-python.hxml
 --next compile-python.hxml
 --next compile-cpp.hxml
 --next compile-cpp.hxml
+--next compile-cs.hxml
 --next compile-java.hxml
 --next compile-java.hxml