Skip to content

Commit

Permalink
std.fmt.parse_float: disable failing aarch64 test from LLVM 14
Browse files Browse the repository at this point in the history
See #12027
  • Loading branch information
andrewrk committed Jul 6, 2022
1 parent 222ea69 commit 18950e8
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/std/fmt/parse_float.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub const parseFloat = @import("parse_float/parse_float.zig").parseFloat;
pub const ParseFloatError = @import("parse_float/parse_float.zig").ParseFloatError;

const builtin = @import("builtin");
const std = @import("std");
const math = std.math;
const testing = std.testing;
Expand All @@ -14,8 +15,6 @@ const epsilon = 1e-7;

test "fmt.parseFloat" {
inline for ([_]type{ f16, f32, f64, f128 }) |T| {
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);

try testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
try testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
try testing.expectError(error.InvalidCharacter, parseFloat(T, "1abc"));
Expand All @@ -40,10 +39,6 @@ test "fmt.parseFloat" {
try expectEqual(try parseFloat(T, "1e-5000"), 0);
try expectEqual(try parseFloat(T, "1e+5000"), std.math.inf(T));

try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T)));
try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
try expectEqual(try parseFloat(T, "-INF"), -std.math.inf(T));

try expectEqual(try parseFloat(T, "0.4e0066999999999999999999999999999999999999999999999999999"), std.math.inf(T));
try expect(approxEqAbs(T, try parseFloat(T, "0_1_2_3_4_5_6.7_8_9_0_0_0e0_0_1_0"), @as(T, 123456.789000e10), epsilon));

Expand Down Expand Up @@ -74,6 +69,23 @@ test "fmt.parseFloat" {
}
}

test "fmt.parseFloat nan and inf" {
if ((builtin.zig_backend == .stage1 or builtin.zig_backend == .stage2_llvm) and
builtin.cpu.arch == .aarch64)
{
// https://github.com/ziglang/zig/issues/12027
return error.SkipZigTest;
}

inline for ([_]type{ f16, f32, f64, f128 }) |T| {
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);

try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T)));
try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
try expectEqual(try parseFloat(T, "-INF"), -std.math.inf(T));
}
}

test "fmt.parseFloat #11169" {
try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0);
}
Expand Down

0 comments on commit 18950e8

Please sign in to comment.