Browse Source

fixed issue #536

Nicolas Cannasse 14 years ago
parent
commit
04770c8aa5
4 changed files with 7 additions and 6 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 1 1
      std/neko/Boot.hx
  3. 4 4
      std/php/Boot.hx
  4. 1 1
      tests/unit/TestReflect.hx

+ 1 - 0
doc/CHANGES.txt

@@ -11,6 +11,7 @@
 	js/php/neko : added haxe.web.Request
 	all : added Std.format
 	js : trace() output fallback on console.log if no id="haxe:trace"
+	all : ensure that Std.is(2.0,Int) returns true on all platforms
 
 2011-09-25: 2.08
 	js : added js.JQuery

+ 1 - 1
std/neko/Boot.hx

@@ -73,7 +73,7 @@ class Boot {
 				return true;
 			switch __dollar__typeof(o) {
 			case __dollar__tint: return (cl == Int || cl == Float);
-			case __dollar__tfloat: return cl == Float;
+			case __dollar__tfloat: return cl == Float || (cl == Int && __dollar__int(o) == o);
 			case __dollar__tbool: return cl == Bool;
 			case __dollar__tobject:
 				if( cl == null )

+ 4 - 4
std/php/Boot.hx

@@ -15,7 +15,7 @@ function _hx_add($a, $b) {
 		return $a + $b;
 	}
 }
-		
+
 function _hx_anonymous($arr = array()) {
 	$o = new _hx_anonymous();
 	foreach($arr as $k => $v)
@@ -52,7 +52,7 @@ class _hx_array implements ArrayAccess, IteratorAggregate {
 	function iterator() {
 		return new _hx_array_iterator($this->»a);
 	}
-	
+
 	function getIterator() {
 		return $this->iterator();
 	}
@@ -367,7 +367,7 @@ function _hx_instanceof($v, $t) {
 		case 'Array'  : return is_array($v);
 		case 'String' : return is_string($v) && !_hx_is_lambda($v);
 		case 'Bool'   : return is_bool($v);
-		case 'Int'    : return is_int($v);
+		case 'Int'    : return is_int($v) || (is_float($v) && intval($v) == $v);
 		case 'Float'  : return is_float($v) || is_int($v);
 		case 'Dynamic': return true;
 		case 'Class'  : return ($v instanceof _hx_class || $v instanceof _hx_interface) && $v->__tname__ != 'Enum';
@@ -570,7 +570,7 @@ function _hx_string_rec($o, $s) {
 		{
 			if ($first && $k === 0)
 				$assoc = false;
-			$str .= ($first ? '' : ', ') . ($assoc 
+			$str .= ($first ? '' : ', ') . ($assoc
 				? _hx_string_rec($k, $s) . '=>' . _hx_string_rec($o[$k], $s)
 				: _hx_string_rec($o[$k], $s)
 			);

+ 1 - 1
tests/unit/TestReflect.hx

@@ -56,7 +56,7 @@ class TestReflect extends Test {
 		is(0,Int,Float);
 		is(1,Int,Float);
 		is(-1,Int,Float);
-		// unspec : is(1.0,Int,Float);
+		is(2.0,Int,Float);
 		is(1.2,Float);
 		is(1e10,Float);
 		is(-1e10,Float);