Skip to content

Commit 8f46026

Browse files
committed
remove indentation changes
1 parent 9f1b1af commit 8f46026

2 files changed

Lines changed: 311 additions & 312 deletions

File tree

test/fixed.jl

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -50,120 +50,120 @@ function test_fixed(::Type{T}, f) where {T}
5050
end
5151

5252
@testset "conversion" begin
53-
@test isapprox(convert(Fixed{Int8,7}, 0.8), 0.797, atol=0.001)
54-
@test isapprox(convert(Fixed{Int8,7}, 0.9), 0.898, atol=0.001)
55-
@test_throws InexactError convert(Fixed{Int8, 7}, 0.999)
56-
@test_throws InexactError convert(Fixed{Int8, 7}, 1.0)
57-
@test_throws InexactError convert(Fixed{Int8, 7}, 1)
58-
@test_throws InexactError convert(Fixed{Int8, 7}, 2)
59-
@test_throws InexactError convert(Fixed{Int8, 7}, 128)
53+
@test isapprox(convert(Fixed{Int8,7}, 0.8), 0.797, atol=0.001)
54+
@test isapprox(convert(Fixed{Int8,7}, 0.9), 0.898, atol=0.001)
55+
@test_throws InexactError convert(Fixed{Int8, 7}, 0.999)
56+
@test_throws InexactError convert(Fixed{Int8, 7}, 1.0)
57+
@test_throws InexactError convert(Fixed{Int8, 7}, 1)
58+
@test_throws InexactError convert(Fixed{Int8, 7}, 2)
59+
@test_throws InexactError convert(Fixed{Int8, 7}, 128)
6060
end
6161

6262
@testset "test_fixed" begin
63-
for (TI, f) in [(Int8, 8), (Int16, 8), (Int16, 10), (Int32, 16)]
64-
T = Fixed{TI,f}
65-
println(" Testing $T")
66-
test_fixed(T, f)
67-
end
63+
for (TI, f) in [(Int8, 8), (Int16, 8), (Int16, 10), (Int32, 16)]
64+
T = Fixed{TI,f}
65+
println(" Testing $T")
66+
test_fixed(T, f)
67+
end
6868
end
6969

7070
@testset "modulus" begin
71-
T = Fixed{Int8,7}
72-
for i = -1.0:0.1:typemax(T)
73-
@test i % T === T(i)
74-
end
75-
@test ( 1.5 % T).i == round(Int, 1.5*128) % Int8
76-
@test (-0.3 % T).i == round(Int, -0.3*128) % Int8
71+
T = Fixed{Int8,7}
72+
for i = -1.0:0.1:typemax(T)
73+
@test i % T === T(i)
74+
end
75+
@test ( 1.5 % T).i == round(Int, 1.5*128) % Int8
76+
@test (-0.3 % T).i == round(Int, -0.3*128) % Int8
7777

78-
T = Fixed{Int16,9}
79-
for i = -64.0:0.1:typemax(T)
80-
@test i % T === T(i)
81-
end
82-
@test ( 65.2 % T).i == round(Int, 65.2*512) % Int16
83-
@test (-67.2 % T).i == round(Int, -67.2*512) % Int16
78+
T = Fixed{Int16,9}
79+
for i = -64.0:0.1:typemax(T)
80+
@test i % T === T(i)
81+
end
82+
@test ( 65.2 % T).i == round(Int, 65.2*512) % Int16
83+
@test (-67.2 % T).i == round(Int, -67.2*512) % Int16
8484
end
8585

8686
@testset "testapprox" begin
87-
for T in [Fixed{Int8,7}, Fixed{Int16,8}, Fixed{Int16,10}]
88-
testapprox(T) # defined in ufixed.jl
89-
end
87+
for T in [Fixed{Int8,7}, Fixed{Int16,8}, Fixed{Int16,10}]
88+
testapprox(T) # defined in ufixed.jl
89+
end
9090
end
9191

9292
@testset "reductions" begin
93-
F8 = Fixed{Int8,8}
94-
a = F8[0.498, 0.1]
95-
acmp = convert(Float64, a[1]) + convert(Float64, a[2])
96-
@test sum(a) == acmp
97-
@test sum(a, dims=1) == [acmp]
98-
99-
F6 = Fixed{Int8,6}
100-
a = F6[1.2, 1.4]
101-
acmp = convert(Float64, a[1])*convert(Float64, a[2])
102-
@test prod(a) == acmp
103-
@test prod(a, dims=1) == [acmp]
93+
F8 = Fixed{Int8,8}
94+
a = F8[0.498, 0.1]
95+
acmp = convert(Float64, a[1]) + convert(Float64, a[2])
96+
@test sum(a) == acmp
97+
@test sum(a, dims=1) == [acmp]
98+
99+
F6 = Fixed{Int8,6}
100+
a = F6[1.2, 1.4]
101+
acmp = convert(Float64, a[1])*convert(Float64, a[2])
102+
@test prod(a) == acmp
103+
@test prod(a, dims=1) == [acmp]
104104
end
105105

106106
@testset "convert result type" begin
107-
x = Fixed{Int8,8}(0.3)
108-
for T in (Float16, Float32, Float64, BigFloat)
109-
y = convert(T, x)
110-
@test isa(y, T)
111-
end
107+
x = Fixed{Int8,8}(0.3)
108+
for T in (Float16, Float32, Float64, BigFloat)
109+
y = convert(T, x)
110+
@test isa(y, T)
111+
end
112112
end
113113

114114
@testset "Integer conversions" begin
115-
@test convert(Int, Q1f6(1)) === 1
116-
@test convert(Integer, Q1f6(1)) === Int8(1)
115+
@test convert(Int, Q1f6(1)) === 1
116+
@test convert(Integer, Q1f6(1)) === Int8(1)
117117
end
118118

119119
@testset "Floating-point conversions" begin
120-
@test isa(float(one(Fixed{Int8,6})), Float32)
121-
@test isa(float(one(Fixed{Int32,18})), Float64)
122-
@test isa(float(one(Fixed{Int32,25})), Float64)
120+
@test isa(float(one(Fixed{Int8,6})), Float32)
121+
@test isa(float(one(Fixed{Int32,18})), Float64)
122+
@test isa(float(one(Fixed{Int32,25})), Float64)
123123
end
124124

125125
@testset "Show" begin
126-
x = Fixed{Int32,5}(0.25)
127-
iob = IOBuffer()
128-
show(iob, x)
129-
str = String(take!(iob))
130-
@test str == "0.25Q26f5"
131-
@test eval(Meta.parse(str)) == x
126+
x = Fixed{Int32,5}(0.25)
127+
iob = IOBuffer()
128+
show(iob, x)
129+
str = String(take!(iob))
130+
@test str == "0.25Q26f5"
131+
@test eval(Meta.parse(str)) == x
132132
end
133133

134134
@testset "rand" begin
135-
for T in (Fixed{Int8,8}, Fixed{Int16,8}, Fixed{Int16,10}, Fixed{Int32,16})
136-
a = rand(T)
137-
@test isa(a, T)
138-
a = rand(T, (3, 5))
139-
@test ndims(a) == 2 && eltype(a) == T
140-
@test size(a) == (3,5)
141-
end
135+
for T in (Fixed{Int8,8}, Fixed{Int16,8}, Fixed{Int16,10}, Fixed{Int32,16})
136+
a = rand(T)
137+
@test isa(a, T)
138+
a = rand(T, (3, 5))
139+
@test ndims(a) == 2 && eltype(a) == T
140+
@test size(a) == (3,5)
141+
end
142142
end
143143

144144
@testset "realmin" begin
145-
# issue #79
146-
@test realmin(Q11f4) == Q11f4(0.06)
145+
# issue #79
146+
@test realmin(Q11f4) == Q11f4(0.06)
147147
end
148148

149149
@testset "Disambiguation constructors" begin
150-
@test_throws ArgumentError Fixed{Int32,16}('a')
151-
@test_throws InexactError Fixed{Int32,16}(complex(1.0, 1.0))
152-
@test Fixed{Int32,16}(complex(1.0, 0.0)) == 1
153-
@test Fixed{Int32,16}(Base.TwicePrecision(1.0, 0.0)) == 1
150+
@test_throws ArgumentError Fixed{Int32,16}('a')
151+
@test_throws InexactError Fixed{Int32,16}(complex(1.0, 1.0))
152+
@test Fixed{Int32,16}(complex(1.0, 0.0)) == 1
153+
@test Fixed{Int32,16}(Base.TwicePrecision(1.0, 0.0)) == 1
154154
end
155155

156156
@testset "fractional fixed-point numbers" begin
157-
# test all-fractional fixed-point numbers (issue #104)
158-
for (T, f) in ((Int8, 7),
159-
(Int16, 15),
160-
(Int32, 31),
161-
(Int64, 63))
162-
tmax = typemax(Fixed{T, f})
163-
@test tmax == BigInt(typemax(T)) / BigInt(2)^f
164-
tol = (tmax + BigFloat(1.0)) / (sizeof(T) * 8)
165-
for x in range(-1, stop=convert(BigFloat, tmax)-tol, length=50)
166-
@test abs(Fixed{T, f}(x) - x) <= tol
167-
end
157+
# test all-fractional fixed-point numbers (issue #104)
158+
for (T, f) in ((Int8, 7),
159+
(Int16, 15),
160+
(Int32, 31),
161+
(Int64, 63))
162+
tmax = typemax(Fixed{T, f})
163+
@test tmax == BigInt(typemax(T)) / BigInt(2)^f
164+
tol = (tmax + BigFloat(1.0)) / (sizeof(T) * 8)
165+
for x in range(-1, stop=convert(BigFloat, tmax)-tol, length=50)
166+
@test abs(Fixed{T, f}(x) - x) <= tol
168167
end
169168
end
169+
end

0 commit comments

Comments
 (0)