aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-03-22 16:21:56 -0400
committerGitHub <noreply@github.com>2019-03-22 16:21:56 -0400
commit6272847917be186fa83f92b0580ed27f459014bd (patch)
tree85b35863cc49d4c5c83c05e6d6dffb3f0a8a83a9 /test
parent1ca78e39e4497821df352e0343132228e08894c3 (diff)
parent02767690e0084ccbad2268c4f4abb0b2d2e8c30a (diff)
downloadzig-6272847917be186fa83f92b0580ed27f459014bd.tar.gz
zig-6272847917be186fa83f92b0580ed27f459014bd.zip
Merge pull request #2094 from ziglang/f128-decimal-literal
float literals now parse using musl's 128 bit float code
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig4
-rw-r--r--test/stage1/behavior/eval.zig8
-rw-r--r--test/stage1/behavior/math.zig9
3 files changed, 13 insertions, 8 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 27a5432fdd..e1e3f715c2 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -4774,7 +4774,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"float literal too large error",
\\comptime {
- \\ const a = 0x1.0p16384;
+ \\ const a = 0x1.0p18495;
\\}
,
"tmp.zig:2:15: error: float literal out of range of any type",
@@ -4783,7 +4783,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"float literal too small error (denormal)",
\\comptime {
- \\ const a = 0x1.0p-16384;
+ \\ const a = 0x1.0p-19000;
\\}
,
"tmp.zig:2:15: error: float literal out of range of any type",
diff --git a/test/stage1/behavior/eval.zig b/test/stage1/behavior/eval.zig
index 5976761f77..6d5ede418e 100644
--- a/test/stage1/behavior/eval.zig
+++ b/test/stage1/behavior/eval.zig
@@ -385,10 +385,10 @@ test "@setEvalBranchQuota" {
}
}
-// TODO test "float literal at compile time not lossy" {
-// TODO expect(16777216.0 + 1.0 == 16777217.0);
-// TODO expect(9007199254740992.0 + 1.0 == 9007199254740993.0);
-// TODO }
+test "float literal at compile time not lossy" {
+ expect(16777216.0 + 1.0 == 16777217.0);
+ expect(9007199254740992.0 + 1.0 == 9007199254740993.0);
+}
test "f32 at compile time is lossy" {
expect(f32(1 << 24) + 1 == 1 << 24);
diff --git a/test/stage1/behavior/math.zig b/test/stage1/behavior/math.zig
index 9b277ce91a..5d10887d32 100644
--- a/test/stage1/behavior/math.zig
+++ b/test/stage1/behavior/math.zig
@@ -324,11 +324,11 @@ test "quad hex float literal parsing accurate" {
}
{
var f: f128 = 0x1.353e45674d89abacc3a2ebf3ff4ffp-50;
- expect(@bitCast(u128, f) == 0x3fcd353e45674d89abacc3a2ebf3ff4f);
+ expect(@bitCast(u128, f) == 0x3fcd353e45674d89abacc3a2ebf3ff50);
}
{
var f: f128 = 0x1.ed8764648369535adf4be3214567fp-9;
- expect(@bitCast(u128, f) == 0x3ff6ed8764648369535adf4be3214567);
+ expect(@bitCast(u128, f) == 0x3ff6ed8764648369535adf4be3214568);
}
const exp2ft = []f64{
0x1.6a09e667f3bcdp-1,
@@ -597,3 +597,8 @@ test "vector integer addition" {
S.doTheTest();
comptime S.doTheTest();
}
+
+test "binary and octal float literals" {
+ expect(0b10100.00010e0 == 0x1.4100000000000p+4);
+ expect(0o10700.00010e0 == 0x1.1c00010000000p+12);
+}