Skip to content

Commit

Permalink
Fix a broken unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ike709 committed Nov 28, 2024
1 parent 12b9f6e commit f563287
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/proc/RunTest()
var/a = 1#INF
var/b = -1#INF
var/c = -1#IND
ASSERT("[a]" == "inf")
ASSERT("[b]" == "-inf")
ASSERT("[c]" == "nan")
7 changes: 7 additions & 0 deletions OpenDreamRuntime/DreamValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ public string Stringify() {
case DreamValueType.Float:
var floatValue = MustGetValueAsFloat();

if (float.IsInfinity(floatValue)) {
var str = float.IsPositiveInfinity(floatValue) ? "inf" : "-inf";
return str;
}

if (floatValue > 16777216f) {
return floatValue.ToString("g6");
}
Expand All @@ -371,6 +376,8 @@ public string Stringify() {
return floatValue.ToString("g8");
}

if (float.IsNaN(floatValue)) return "nan";

return floatValue.ToString("g6");

case DreamValueType.DreamResource:
Expand Down

0 comments on commit f563287

Please sign in to comment.