| ... | ... | @@ -155,15 +155,14 @@ test "@sin" { |
| 155 | 155 | |
| 156 | 156 | fn testSin() !void { |
| 157 | 157 | // stage1 emits an incorrect compile error for `@as(ty, std.math.pi / 2)` |
| 158 | | // so skip the rest of the tests. |
| 159 | | if (builtin.zig_backend != .stage1) { |
| 160 | | inline for ([_]type{ f16, f32, f64 }) |ty| { |
| 161 | | const eps = epsForType(ty); |
| 162 | | try expect(@sin(@as(ty, 0)) == 0); |
| 163 | | try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi)), 0, eps)); |
| 164 | | try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 2)), 1, eps)); |
| 165 | | try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps)); |
| 166 | | } |
| 158 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 159 | |
| 160 | inline for ([_]type{ f16, f32, f64 }) |ty| { |
| 161 | const eps = epsForType(ty); |
| 162 | try expect(@sin(@as(ty, 0)) == 0); |
| 163 | try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi)), 0, eps)); |
| 164 | try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 2)), 1, eps)); |
| 165 | try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps)); |
| 167 | 166 | } |
| 168 | 167 | |
| 169 | 168 | { |
| ... | ... | @@ -183,15 +182,14 @@ test "@cos" { |
| 183 | 182 | |
| 184 | 183 | fn testCos() !void { |
| 185 | 184 | // stage1 emits an incorrect compile error for `@as(ty, std.math.pi / 2)` |
| 186 | | // so skip the rest of the tests. |
| 187 | | if (builtin.zig_backend != .stage1) { |
| 188 | | inline for ([_]type{ f16, f32, f64 }) |ty| { |
| 189 | | const eps = epsForType(ty); |
| 190 | | try expect(@cos(@as(ty, 0)) == 1); |
| 191 | | try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi)), -1, eps)); |
| 192 | | try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 2)), 0, eps)); |
| 193 | | try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps)); |
| 194 | | } |
| 185 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 186 | |
| 187 | inline for ([_]type{ f16, f32, f64 }) |ty| { |
| 188 | const eps = epsForType(ty); |
| 189 | try expect(@cos(@as(ty, 0)) == 1); |
| 190 | try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi)), -1, eps)); |
| 191 | try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 2)), 0, eps)); |
| 192 | try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps)); |
| 195 | 193 | } |
| 196 | 194 | |
| 197 | 195 | { |