304 (a) -> assertCommand(a, "/debug", "| Debugging on\n"), |
304 (a) -> assertCommand(a, "/debug", "| Debugging on\n"), |
305 (a) -> assertCommand(a, "/deb", "| Debugging off\n") |
305 (a) -> assertCommand(a, "/deb", "| Debugging off\n") |
306 ); |
306 ); |
307 } |
307 } |
308 |
308 |
309 public void testHelp() { |
309 public void testHelpLength() { |
310 Consumer<String> testOutput = (s) -> { |
310 Consumer<String> testOutput = (s) -> { |
311 List<String> ss = Stream.of(s.split("\n")) |
311 List<String> ss = Stream.of(s.split("\n")) |
312 .filter(l -> !l.isEmpty()) |
312 .filter(l -> !l.isEmpty()) |
313 .collect(Collectors.toList()); |
313 .collect(Collectors.toList()); |
314 assertTrue(ss.size() >= 5, "Help does not print enough lines:\n" + s); |
314 assertTrue(ss.size() >= 10, "Help does not print enough lines:\n" + s); |
315 }; |
315 }; |
316 test( |
316 test( |
317 (a) -> assertCommandCheckOutput(a, "/?", testOutput), |
317 (a) -> assertCommandCheckOutput(a, "/?", testOutput), |
318 (a) -> assertCommandCheckOutput(a, "/help", testOutput) |
318 (a) -> assertCommandCheckOutput(a, "/help", testOutput), |
319 ); |
319 (a) -> assertCommandCheckOutput(a, "/help /list", testOutput) |
|
320 ); |
|
321 } |
|
322 |
|
323 public void testHelp() { |
|
324 test( |
|
325 (a) -> assertHelp(a, "/?", "/list", "/help", "/exit", "intro"), |
|
326 (a) -> assertHelp(a, "/help", "/list", "/help", "/exit", "intro"), |
|
327 (a) -> assertHelp(a, "/help short", "shortcuts", "<tab>"), |
|
328 (a) -> assertHelp(a, "/? /li", "/list all", "snippets"), |
|
329 (a) -> assertHelp(a, "/help /help", "/help <command>") |
|
330 ); |
|
331 } |
|
332 |
|
333 private void assertHelp(boolean a, String command, String... find) { |
|
334 assertCommandCheckOutput(a, command, s -> { |
|
335 for (String f : find) { |
|
336 assertTrue(s.contains(f), "Expected output of " + command + " to contain: " + f); |
|
337 } |
|
338 }); |
320 } |
339 } |
321 |
340 |
322 public void oneLineOfError() { |
341 public void oneLineOfError() { |
323 test( |
342 test( |
324 (a) -> assertCommand(a, "12+", null), |
343 (a) -> assertCommand(a, "12+", null), |
680 s -> assertEquals(s, "| No definition or id named " + arg + |
699 s -> assertEquals(s, "| No definition or id named " + arg + |
681 " found. There are no active definitions.\n")), |
700 " found. There are no active definitions.\n")), |
682 a -> assertVariable(a, "int", "aardvark"), |
701 a -> assertVariable(a, "int", "aardvark"), |
683 a -> assertCommandCheckOutput(a, "/list aardvark", |
702 a -> assertCommandCheckOutput(a, "/list aardvark", |
684 s -> assertTrue(s.contains("aardvark"))), |
703 s -> assertTrue(s.contains("aardvark"))), |
|
704 a -> assertCommandCheckOutput(a, "/list start", |
|
705 s -> checkLineToList(s, START_UP)), |
685 a -> assertCommandCheckOutput(a, "/list all", |
706 a -> assertCommandCheckOutput(a, "/list all", |
686 s -> checkLineToList(s, startVarList)), |
707 s -> checkLineToList(s, startVarList)), |
687 a -> assertCommandCheckOutput(a, "/list history", |
708 a -> assertCommandCheckOutput(a, "/list printf", |
688 s -> assertTrue(s.split("\n").length >= 4, s)), |
709 s -> assertTrue(s.contains("void printf"))), |
689 a -> assertCommandCheckOutput(a, "/list " + arg, |
710 a -> assertCommandCheckOutput(a, "/list " + arg, |
690 s -> assertEquals(s, "| No definition or id named " + arg + |
711 s -> assertEquals(s, "| No definition or id named " + arg + |
691 " found. Try /list without arguments.\n")) |
712 " found. Try /list without arguments.\n")) |
692 ); |
713 ); |
693 } |
714 } |