Skip to content

Commit 77e8cb0

Browse files
committed
Fix: FromJson (neg integers)
1 parent 8f0af7b commit 77e8cb0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

NeoLua.Test/LuaTable.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,8 @@ public void TestJsonDateTime()
13961396
[TestMethod]
13971397
public void TestFromJson01()
13981398
{
1399-
dynamic t = LuaTable.FromJson("{ \"a\":true, \"b\" : false, \"c\": 10, \"d\": 1099511627776, \"e\": \"test\", \"f\": 1.0, \"g\": 1.23, \"h\": 1e10 }");
1400-
TestResult(new LuaResult(t.a, t.b, t.c, t.d, t.e, t.f, t.g, t.h), true, false, 10, 1099511627776L, "test", 1.0, 1.23, 1e10);
1399+
dynamic t = LuaTable.FromJson("{ \"a\":true, \"b\" : false, \"c\": -10, \"d\": 1099511627776, \"e\": \"test\", \"f\": 1.0, \"g\": 1.23, \"h\": 1e10 }");
1400+
TestResult(new LuaResult(t.a, t.b, t.c, t.d, t.e, t.f, t.g, t.h), true, false, -10, 1099511627776L, "test", 1.0, 1.23, 1e10);
14011401
}
14021402
} // class LuaTableTests
14031403
}

NeoLua/LuaTable.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4509,9 +4509,9 @@ object ParseNumber()
45094509
return doubleValue;
45104510
}
45114511
else if (integerValue < Int32.MaxValue)
4512-
return (int)integerValue;
4512+
return isNeg ? -(int)integerValue : (int)integerValue;
45134513
else
4514-
return integerValue;
4514+
return isNeg ? -integerValue : integerValue;
45154515
} // func ParseNumber
45164516

45174517
string ParseString(bool asMember)

0 commit comments

Comments
 (0)