|
35 | 35 | import java.io.InputStream;
|
36 | 36 | import java.io.InputStreamReader;
|
37 | 37 | import java.io.Reader;
|
| 38 | +import java.util.Collection; |
38 | 39 | import java.util.LinkedList;
|
39 | 40 | import java.util.concurrent.atomic.AtomicInteger;
|
40 | 41 |
|
@@ -216,6 +217,56 @@ public void testEvalThrow() throws Throwable {
|
216 | 217 | assertExecutedOK("OK");
|
217 | 218 | }
|
218 | 219 |
|
| 220 | + @Ignore |
| 221 | + @Test |
| 222 | + public void testProperties() throws Throwable { |
| 223 | + Source source = getSource("src/test/ruby/types.rb"); |
| 224 | + run.addLast(() -> { |
| 225 | + assertNull(suspendedEvent); |
| 226 | + assertNotNull(debuggerSession); |
| 227 | + breakpoint = Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(27).build(); |
| 228 | + debuggerSession.install(breakpoint); |
| 229 | + }); |
| 230 | + assertLocation(27, "nme + nm1", |
| 231 | + "name", "\"Panama\"", // Possible bug: should really the quotes be included? |
| 232 | + "cityArray", "[80, 97, 110, 97, 109, 97]", |
| 233 | + "citySum", "590", |
| 234 | + "weatherTemperature", "14", |
| 235 | + "blt", "true", |
| 236 | + "blf", "false", |
| 237 | + "null", "nil", |
| 238 | + "nm1", "1", |
| 239 | + "nm11", "1.111", |
| 240 | + "nme", "3.5e+46", |
| 241 | + "nc", "(2+3i)", |
| 242 | + "nr", "(5404319552844595/18014398509481984)", |
| 243 | + "str", "\"A String\"", |
| 244 | + "symbol", ":symbolic", |
| 245 | + "arr", "[1, \"2\", 3.56, true, nil, \"A String\"]", |
| 246 | + "hash", "{:a=>1, \"b\"=>2}"); |
| 247 | + run.addLast(() -> { |
| 248 | + final DebugStackFrame frame = suspendedEvent.getTopStackFrame(); |
| 249 | + DebugValue value = frame.getScope().getDeclaredValue("name"); |
| 250 | + Collection<DebugValue> properties = value.getProperties(); |
| 251 | + assertTrue("String has " + properties.size() + " properties.", properties.size() > 0); // BUG: String have no properties |
| 252 | + value = frame.getScope().getDeclaredValue("hash"); |
| 253 | + properties = value.getProperties(); |
| 254 | + assertEquals(2, properties.size()); // 'hash' has two properties |
| 255 | + try { |
| 256 | + properties.iterator().next().as(String.class); |
| 257 | + } catch (IllegalStateException ex) { |
| 258 | + "Value is not readable".equals(ex.getMessage()); // BUG |
| 259 | + Assert.fail(ex.getMessage()); |
| 260 | + } |
| 261 | + assertNotNull(value.getProperty("a")); // == null, BUG |
| 262 | + assertEquals(0, frame.getScope().getDeclaredValue("symbol").getProperties().size()); |
| 263 | + assertEquals(6, frame.getScope().getDeclaredValue("arr").getArray().size()); |
| 264 | + }); |
| 265 | + performWork(); |
| 266 | + context.eval(source); |
| 267 | + assertExecutedOK("OK"); |
| 268 | + } |
| 269 | + |
219 | 270 | private void performWork() {
|
220 | 271 | try {
|
221 | 272 | if (ex == null && !run.isEmpty()) {
|
|
0 commit comments