|
13 | 13 | describe "Java null" do
|
14 | 14 | it "gives a similar representation to Ruby" do
|
15 | 15 | foreign = Truffle::Debug.java_null
|
16 |
| - foreign.inspect.should == "#<Java null>" |
17 |
| - foreign.to_s.should == "#<Java null>" |
| 16 | + foreign.inspect.should == "#<Polyglot::ForeignNull[Java] null>" |
| 17 | + foreign.to_s.should == "#<Polyglot::ForeignNull[Java] null>" |
18 | 18 | end
|
19 | 19 | end
|
20 | 20 |
|
21 | 21 | describe "Java list" do
|
22 | 22 | it "gives a similar representation to Ruby" do
|
23 | 23 | foreign = Truffle::Interop.to_java_list([1, 2, 3])
|
24 |
| - foreign.inspect.should =~ /\A#<Java java\.util\.Arrays\$ArrayList:0x\h+ \[1, 2, 3\]>\z/ |
25 |
| - foreign.to_s.should == "#<Java [1, 2, 3]>" |
| 24 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignArray\[Java\] java\.util\.Arrays\$ArrayList:0x\h+ \[1, 2, 3\]>\z/ |
| 25 | + foreign.to_s.should == "#<Polyglot::ForeignArray[Java] [1, 2, 3]>" |
26 | 26 | end
|
27 | 27 | end
|
28 | 28 |
|
29 | 29 | describe "Java array" do
|
30 | 30 | it "gives a similar representation to Ruby" do
|
31 | 31 | foreign = Truffle::Interop.to_java_array([1, 2, 3])
|
32 |
| - foreign.inspect.should =~ /\A#<Java int\[\]:0x\h+ \[1, 2, 3\]>\z/ |
33 |
| - foreign.to_s.should == "#<Java [1, 2, 3]>" |
| 32 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignArray\[Java\] int\[\]:0x\h+ \[1, 2, 3\]>\z/ |
| 33 | + foreign.to_s.should == "#<Polyglot::ForeignArray[Java] [1, 2, 3]>" |
34 | 34 | end
|
35 | 35 | end
|
36 | 36 |
|
|
40 | 40 | foreign = Truffle::Interop.to_java_map(hash)
|
41 | 41 |
|
42 | 42 | hash.to_s.should == '{:a=>1, :b=>2, :c=>3}' # for comparison
|
43 |
| - foreign.inspect.should =~ /\A#<Java java\.util\.HashMap:0x\h+ {"a"=>1, "b"=>2, "c"=>3}>\z/ |
44 |
| - foreign.to_s.should == "#<Java {a=1, b=2, c=3}>" |
| 43 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignObject\[Java\] java\.util\.HashMap:0x\h+ {"a"=>1, "b"=>2, "c"=>3}>\z/ |
| 44 | + foreign.to_s.should == "#<Polyglot::ForeignObject[Java] {a=1, b=2, c=3}>" |
45 | 45 | end
|
46 | 46 | end
|
47 | 47 |
|
48 | 48 | describe "Java class" do
|
49 | 49 | it "gives a similar representation to Ruby" do
|
50 | 50 | foreign = Truffle::Interop.java_type("java.math.BigInteger")
|
51 |
| - foreign.inspect.should == "#<Java class java.math.BigInteger>" |
52 |
| - foreign.to_s.should == "#<Java java.math.BigInteger>" |
| 51 | + foreign.inspect.should == "#<Polyglot::ForeignInstantiable[Java] class java.math.BigInteger>" |
| 52 | + foreign.to_s.should == "#<Polyglot::ForeignInstantiable[Java] java.math.BigInteger>" |
53 | 53 | end
|
54 | 54 | end
|
55 | 55 |
|
56 | 56 | describe "Java object" do
|
57 | 57 | it "gives a similar representation to Ruby" do
|
58 | 58 | foreign = Truffle::Interop.java_type("java.math.BigInteger").new('14')
|
59 |
| - foreign.inspect.should =~ /\A#<Java java\.math\.BigInteger:0x\h+ .+>\z/ |
60 |
| - foreign.to_s.should == "#<Java 14>" |
| 59 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignObject\[Java\] java\.math\.BigInteger:0x\h+ .+>\z/ |
| 60 | + foreign.to_s.should == "#<Polyglot::ForeignObject[Java] 14>" |
61 | 61 | end
|
62 | 62 | end
|
63 | 63 | end
|
|
67 | 67 | x = [1, 2, 3]
|
68 | 68 | foreign = Truffle::Debug.foreign_array_from_java(Truffle::Interop.to_java_array(x))
|
69 | 69 | foreign[0] = foreign
|
70 |
| - foreign.inspect.should =~ /\A#<Foreign:0x\h+ \[\[...\], 2, 3\]>\z/ |
71 |
| - foreign.to_s.should == "#<Foreign [foreign array]>" |
| 70 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignArray:0x\h+ \[\[...\], 2, 3\]>\z/ |
| 71 | + foreign.to_s.should == "#<Polyglot::ForeignArray [foreign array]>" |
72 | 72 | end
|
73 | 73 | end
|
74 | 74 |
|
75 | 75 | describe "null" do
|
76 | 76 | it "gives a similar representation to Ruby" do
|
77 | 77 | foreign = Truffle::Debug.foreign_null
|
78 |
| - foreign.inspect.should == "#<Foreign null>" |
79 |
| - foreign.to_s.should == "#<Foreign [foreign null]>" |
| 78 | + foreign.inspect.should == "#<Polyglot::ForeignNull null>" |
| 79 | + foreign.to_s.should == "#<Polyglot::ForeignNull [foreign null]>" |
80 | 80 | end
|
81 | 81 | end
|
82 | 82 |
|
83 | 83 | describe "executable" do
|
84 | 84 | it "gives a similar representation to Ruby" do
|
85 | 85 | foreign = Truffle::Debug.foreign_executable(14)
|
86 |
| - foreign.inspect.should =~ /\A#<Foreign:0x\h+ proc>\z/ |
87 |
| - foreign.to_s.should == "#<Foreign [foreign executable]>" |
| 86 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignExecutable:0x\h+ proc>\z/ |
| 87 | + foreign.to_s.should == "#<Polyglot::ForeignExecutable [foreign executable]>" |
88 | 88 | end
|
89 | 89 | end
|
90 | 90 |
|
91 | 91 | describe "pointer" do
|
92 | 92 | it "gives a similar representation to Ruby" do
|
93 | 93 | foreign = Truffle::Debug.foreign_pointer(0x1234)
|
94 |
| - foreign.inspect.should == "#<Foreign pointer 0x1234>" |
95 |
| - foreign.to_s.should == "#<Foreign [foreign pointer]>" |
| 94 | + foreign.inspect.should == "#<Polyglot::ForeignPointer 0x1234>" |
| 95 | + foreign.to_s.should == "#<Polyglot::ForeignPointer [foreign pointer]>" |
96 | 96 | end
|
97 | 97 | end
|
98 | 98 |
|
99 | 99 | guard -> { !TruffleRuby.native? } do
|
100 | 100 | describe "array" do
|
101 | 101 | it "gives a similar representation to Ruby" do
|
102 | 102 | foreign = Truffle::Debug.foreign_array_from_java(Truffle::Interop.to_java_array([1, 2, 3]))
|
103 |
| - foreign.inspect.should =~ /\A#<Foreign:0x\h+ \[1, 2, 3\]>\z/ |
104 |
| - foreign.to_s.should == "#<Foreign [foreign array]>" |
| 103 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignArray:0x\h+ \[1, 2, 3\]>\z/ |
| 104 | + foreign.to_s.should == "#<Polyglot::ForeignArray [foreign array]>" |
105 | 105 | end
|
106 | 106 |
|
107 | 107 | it "gives a similar representation to Ruby, even if it is also a pointer" do
|
108 | 108 | foreign = Truffle::Debug.foreign_pointer_array_from_java(Truffle::Interop.to_java_array([1, 2, 3]))
|
109 |
| - foreign.inspect.should =~ /\A#<Foreign pointer 0x\h+ \[1, 2, 3\]>\z/ |
110 |
| - foreign.to_s.should == "#<Foreign [foreign pointer array]>" |
| 109 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignArrayPointer 0x0 \[1, 2, 3\]>\z/ |
| 110 | + foreign.to_s.should == "#<Polyglot::ForeignArrayPointer [foreign pointer array]>" |
111 | 111 | end
|
112 | 112 | end
|
113 | 113 | end
|
|
116 | 116 | describe "object without members" do
|
117 | 117 | it "gives a similar representation to Ruby" do
|
118 | 118 | foreign = Truffle::Debug.foreign_object
|
119 |
| - foreign.inspect.should =~ /\A#<Foreign:0x\h+>\z/ |
120 |
| - foreign.to_s.should == "#<Foreign [foreign object]>" |
| 119 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignObject:0x\h+>\z/ |
| 120 | + foreign.to_s.should == "#<Polyglot::ForeignObject [foreign object]>" |
121 | 121 | end
|
122 | 122 | end
|
123 | 123 |
|
124 | 124 | describe "object with members" do
|
125 | 125 | it "gives a similar representation to Ruby" do
|
126 | 126 | foreign = Truffle::Debug.foreign_object_from_map(Truffle::Interop.to_java_map({a: 1, b: 2, c: 3}))
|
127 |
| - foreign.inspect.should =~ /\A#<Foreign:0x\h+ a=1, b=2, c=3>\z/ |
128 |
| - foreign.to_s.should == "#<Foreign [foreign object with members]>" |
| 127 | + foreign.inspect.should =~ /\A#<Polyglot::ForeignObject:0x\h+ a=1, b=2, c=3>\z/ |
| 128 | + foreign.to_s.should == "#<Polyglot::ForeignObject [foreign object with members]>" |
129 | 129 | end
|
130 | 130 | end
|
131 | 131 | end
|
|
0 commit comments