|
17 | 17 | Base.:(>>)(x::Foo, y::Foo) = "$(x.value) >> $(y.value)"
|
18 | 18 | Base.:(&)(x::Foo, y::Foo) = "$(x.value) & $(y.value)"
|
19 | 19 | Base.:(|)(x::Foo, y::Foo) = "$(x.value) | $(y.value)"
|
| 20 | + @testset "type" begin |
| 21 | + @test pyis(pytype(pyjl(Foo(1))), PythonCall.pyjlanytype) |
| 22 | + @test pyis(pytype(pyjl(nothing)), PythonCall.pyjlanytype) |
| 23 | + @test pyis(pytype(pyjl(missing)), PythonCall.pyjlanytype) |
| 24 | + end |
| 25 | + @testset "bool" begin |
| 26 | + @test pytruth(pyjl(Foo(0))) |
| 27 | + @test pytruth(pyjl(Foo(1))) |
| 28 | + @test pytruth(pyjl(nothing)) |
| 29 | + @test pytruth(pyjl(missing)) |
| 30 | + end |
20 | 31 | @testset "pos" begin
|
21 | 32 | z = pyjl(+Foo(1))
|
22 | 33 | @test pyconvert(String, z) == "+ 1"
|
|
123 | 134 | end
|
124 | 135 | end
|
125 | 136 |
|
| 137 | +@testitem "array" begin |
| 138 | + @testset "type" begin |
| 139 | + @test pyis(pytype(pyjl(fill(nothing))), PythonCall.pyjlarraytype) |
| 140 | + @test pyis(pytype(pyjl([1 2; 3 4])), PythonCall.pyjlarraytype) |
| 141 | + end |
| 142 | + @testset "bool" begin |
| 143 | + @test !pytruth(pyjl(fill(nothing, 0, 1))) |
| 144 | + @test !pytruth(pyjl(fill(nothing, 1, 0))) |
| 145 | + @test pytruth(pyjl(fill(nothing))) |
| 146 | + @test pytruth(pyjl(fill(nothing, 1, 2))) |
| 147 | + @test pytruth(pyjl(fill(nothing, 1, 2, 3))) |
| 148 | + end |
| 149 | +end |
| 150 | + |
| 151 | +@testitem "base" begin |
| 152 | + |
| 153 | +end |
| 154 | + |
| 155 | +@testitem "callback" begin |
| 156 | + |
| 157 | +end |
| 158 | + |
| 159 | +@testitem "dict" begin |
| 160 | + @testset "type" begin |
| 161 | + @test pyis(pytype(pyjl(Dict())), PythonCall.pyjldicttype) |
| 162 | + end |
| 163 | + @testset "bool" begin |
| 164 | + @test !pytruth(pyjl(Dict())) |
| 165 | + @test pytruth(pyjl(Dict("one"=>1, "two"=>2))) |
| 166 | + end |
| 167 | +end |
| 168 | + |
| 169 | +@testitem "io" begin |
| 170 | + @testset "type" begin |
| 171 | + @test pyis(pytype(pyjl(devnull)), PythonCall.pyjlbinaryiotype) |
| 172 | + @test pyis(pytype(pybinaryio(devnull)), PythonCall.pyjlbinaryiotype) |
| 173 | + @test pyis(pytype(pytextio(devnull)), PythonCall.pyjltextiotype) |
| 174 | + end |
| 175 | + @testset "bool" begin |
| 176 | + @test pytruth(pybinaryio(devnull)) |
| 177 | + @test pytruth(pytextio(devnull)) |
| 178 | + end |
| 179 | +end |
| 180 | + |
126 | 181 | @testitem "iter" begin
|
127 | 182 | x1 = [1,2,3,4,5]
|
128 | 183 | x2 = pyjl(x1)
|
129 | 184 | x3 = pylist(x2)
|
130 | 185 | x4 = pyconvert(Vector{Int}, x3)
|
131 | 186 | @test x1 == x4
|
132 | 187 | end
|
| 188 | + |
| 189 | +@testitem "module" begin |
| 190 | + @testset "type" begin |
| 191 | + @test pyis(pytype(pyjl(PythonCall)), PythonCall.pyjlmoduletype) |
| 192 | + end |
| 193 | + @testset "bool" begin |
| 194 | + @test pytruth(pyjl(PythonCall)) |
| 195 | + end |
| 196 | +end |
| 197 | + |
| 198 | +@testitem "number" begin |
| 199 | + @testset "type" begin |
| 200 | + @test pyis(pytype(pyjl(false)), PythonCall.pyjlintegertype) |
| 201 | + @test pyis(pytype(pyjl(0)), PythonCall.pyjlintegertype) |
| 202 | + @test pyis(pytype(pyjl(0//1)), PythonCall.pyjlrationaltype) |
| 203 | + @test pyis(pytype(pyjl(0.0)), PythonCall.pyjlrealtype) |
| 204 | + @test pyis(pytype(pyjl(Complex(0.0))), PythonCall.pyjlcomplextype) |
| 205 | + end |
| 206 | + @testset "bool" begin |
| 207 | + @test !pytruth(pyjl(false)) |
| 208 | + @test !pytruth(pyjl(0)) |
| 209 | + @test !pytruth(pyjl(0//1)) |
| 210 | + @test !pytruth(pyjl(0.0)) |
| 211 | + @test !pytruth(pyjl(Complex(0.0))) |
| 212 | + @test pytruth(pyjl(true)) |
| 213 | + @test pytruth(pyjl(3)) |
| 214 | + @test pytruth(pyjl(5//2)) |
| 215 | + @test pytruth(pyjl(2.3)) |
| 216 | + @test pytruth(pyjl(Complex(1.2, 3.4))) |
| 217 | + end |
| 218 | +end |
| 219 | + |
| 220 | +@testitem "objectarray" begin |
| 221 | + |
| 222 | +end |
| 223 | + |
| 224 | +@testitem "raw" begin |
| 225 | + |
| 226 | +end |
| 227 | + |
| 228 | +@testitem "set" begin |
| 229 | + @testset "type" begin |
| 230 | + @test pyis(pytype(pyjl(Set())), PythonCall.pyjlsettype) |
| 231 | + end |
| 232 | + @testset "bool" begin |
| 233 | + @test !pytruth(pyjl(Set())) |
| 234 | + @test pytruth(pyjl(Set([1,2,3]))) |
| 235 | + end |
| 236 | +end |
| 237 | + |
| 238 | +@testitem "type" begin |
| 239 | + @testset "type" begin |
| 240 | + @test pyis(pytype(pyjl(Int)), PythonCall.pyjltypetype) |
| 241 | + end |
| 242 | + @testset "bool" begin |
| 243 | + @test pytruth(pyjl(Int)) |
| 244 | + end |
| 245 | +end |
| 246 | + |
| 247 | +@testitem "vector" begin |
| 248 | + @testset "type" begin |
| 249 | + @test pyis(pytype(pyjl([1, 2, 3, 4])), PythonCall.pyjlvectortype) |
| 250 | + end |
| 251 | + @testset "bool" begin |
| 252 | + @test !pytruth(pyjl([])) |
| 253 | + @test pytruth(pyjl([1])) |
| 254 | + @test pytruth(pyjl([1,2])) |
| 255 | + end |
| 256 | +end |
0 commit comments