|
824 | 824 | @test pyjlgetvalue(v) === value |
825 | 825 | end |
826 | 826 |
|
| 827 | + @testset "juliaraw" begin |
| 828 | + xo = pyjlraw(nothing) |
| 829 | + @test @pyv `repr($xo) == "<jl nothing>"`::Bool |
| 830 | + @test @pyv `str($xo) == "nothing"`::Bool |
| 831 | + x = Struct1("foo", 12) |
| 832 | + xo = pyjlraw(x) |
| 833 | + @test (@pyv `$xo.x`::Any) === x.x |
| 834 | + @test (@pyv `$xo.y`::Any) === x.y |
| 835 | + @py `$xo.x = "bar"` |
| 836 | + @test x.x == "bar" |
| 837 | + @test @pyv `"x" in dir($xo)`::Bool |
| 838 | + @test @pyv `"y" in dir($xo)`::Bool |
| 839 | + xo = pyjlraw(+) |
| 840 | + @test (@pyv `$xo(2,3)`::Any) === 5 |
| 841 | + x = [1,2,3] |
| 842 | + xo = pyjlraw(x) |
| 843 | + @test @pyv `len($xo) == 3`::Bool |
| 844 | + @test (@pyv `$xo[1]`::Any) === x[1] |
| 845 | + @test (@pyv `$xo[$(pyjlraw(1:3))]`::Any) == [1,2,3] |
| 846 | + @py `$xo[1] = 0` |
| 847 | + @test x == [0,2,3] |
| 848 | + x = [1 2; 3 4] |
| 849 | + xo = pyjlraw(x) |
| 850 | + @test @pyv `len($xo) == 4`::Bool |
| 851 | + @test (@pyv `$xo[1,2]`::Any) === x[1,2] |
| 852 | + @py `$xo[1,2] = 0` |
| 853 | + @test x == [1 0; 3 4] |
| 854 | + end |
| 855 | + |
827 | 856 | @testset "juliaany" begin |
828 | 857 | for value in Any[nothing, missing, (), identity, push!] |
829 | 858 | @test @pyv `type($(pyjl(value))).__name__ == "AnyValue"`::Bool |
|
948 | 977 | @test @pyv `list($xmv) == [0,3,2,4]`::Bool |
949 | 978 | end |
950 | 979 |
|
| 980 | + @testset "juliavector" begin |
| 981 | + # TODO |
| 982 | + end |
| 983 | + |
| 984 | + @testset "juliaset" begin |
| 985 | + # TODO |
| 986 | + end |
| 987 | + |
| 988 | + @testset "juliadict" begin |
| 989 | + x = Dict("foo"=>1, "bar"=>2, "baz"=>3) |
| 990 | + @test @pyv `set($x) == {"foo", "bar", "baz"}`::Bool |
| 991 | + @test @pyv `set($x.keys()) == {"foo", "bar", "baz"}`::Bool |
| 992 | + @test @pyv `set($x.values()) == {1, 2, 3}`::Bool |
| 993 | + @test @pyv `set($x.items()) == {("foo", 1), ("bar", 2), ("baz", 3)}`::Bool |
| 994 | + @test @pyv `len($x) == 3`::Bool |
| 995 | + @test @pyv `len($x.items()) == 3`::Bool |
| 996 | + @test @pyv `"foo" in $x`::Bool |
| 997 | + @test @pyv `"hello" not in $x`::Bool |
| 998 | + @test @pyv `1 not in $x`::Bool |
| 999 | + @test @pyv `("foo", 1) in $x.items()`::Bool |
| 1000 | + @test @pyv `$x.get("bar") == 2`::Bool |
| 1001 | + @test @pyv `$x.get("hello") is None`::Bool |
| 1002 | + @test @pyv `$x.get(1) is None`::Bool |
| 1003 | + @test @pyv `$x.get("hello", "MISSING") == "MISSING"`::Bool |
| 1004 | + @test @pyv `$x.setdefault("foo", 0) == 1`::Bool |
| 1005 | + @test x["foo"] == 1 |
| 1006 | + @test @pyv `$x.setdefault("bax", 0) == 0`::Bool |
| 1007 | + @test x["bax"] == 0 |
| 1008 | + @test @pyv `$x.pop("bax", None) == 0`::Bool |
| 1009 | + @test @pyv `$x.pop("bax", None) is None`::Bool |
| 1010 | + @test_throws Exception @pyv `$x.pop("bax")` |
| 1011 | + @py `$x.clear()` |
| 1012 | + @test isempty(x) |
| 1013 | + x["foo"] = 1 |
| 1014 | + @test @pyv `$x.popitem() == ("foo", 1)`::Bool |
| 1015 | + @test_throws Exception @pyv `$x.popitem()` |
| 1016 | + @test isempty(x) |
| 1017 | + end |
| 1018 | + |
951 | 1019 | @testset "juliaio" begin |
952 | 1020 | for value in Any[stdin, stdout, IOBuffer()] |
953 | 1021 | @test @pyv `type($(pyjl(value))).__name__ == "BufferedIOValue"`::Bool |
|
0 commit comments