Revision: 5529 http://jnode.svn.sourceforge.net/jnode/?rev=5529&view=rev Author: crawley Date: 2009-05-28 12:06:21 +0000 (Thu, 28 May 2009)
Log Message: ----------- More completion testcases Modified Paths: -------------- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java 2009-05-27 14:29:36 UTC (rev 5528) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/BjorneCompletionTests.java 2009-05-28 12:06:21 UTC (rev 5529) @@ -111,21 +111,129 @@ } public void testIf2Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("if\ncpuid ; then echo hi ; fi", "TTTTTETT"); + } + + public void testIf3Command() throws ShellSyntaxException, CompletionException { doCompletionTest("if cpuid\nthen echo hi ; fi", "TTTTETT"); } - public void testIf3Command() throws ShellSyntaxException, CompletionException { + public void testIf4Command() throws ShellSyntaxException, CompletionException { doCompletionTest("if cpuid ; then\necho hi ; fi", "TTTTTETT"); } - public void testIf4Command() throws ShellSyntaxException, CompletionException { + public void testIf5Command() throws ShellSyntaxException, CompletionException { doCompletionTest("if cpuid ; then\necho hi\nfi", "TTTTTET"); } + public void testIfElseCommand() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; else echo ho ; fi", "TTTTTETTTETT"); + } + + public void testIfElse2Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; else\necho ho ; fi", "TTTTTETTTETT"); + } + + public void testIfElse3Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; else echo ho\nfi", "TTTTTETTTET"); + } + + public void testIfElifCommand() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; elif cpuid ; then echo ho ; fi", "TTTTTETTTTTTETT"); + } + + public void testIfElif2Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; elif\ncpuid ; then echo ho ; fi", "TTTTTETTTTTTETT"); + } + + public void testIfElif3Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; elif cpuid\nthen echo ho ; fi", "TTTTTETTTTTETT"); + } + + public void testIfElif4Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("if cpuid ; then echo hi ; elif cpuid ; then\necho ho ; fi", "TTTTTETTTTTTETT"); + } + public void testWhileCommand() throws ShellSyntaxException, CompletionException { doCompletionTest("while cpuid ; do echo hi ; done", "TTTTTETT"); } + public void testWhile2Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("while\ncpuid ; do echo hi ; done", "TTTTTETT"); + } + + public void testWhile3Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("while cpuid\ndo echo hi ; done", "TTTTETT"); + } + + public void testWhile4Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("while cpuid ; do\necho hi ; done", "TTTTTETT"); + } + + public void testWhile5Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("while cpuid ; do echo hi\ndone", "TTTTTET"); + } + + public void testForCommand() throws ShellSyntaxException, CompletionException { + doCompletionTest("for X in a b c ; do echo hi ; done", "TFTFEETTTETT"); + } + + public void testFor2Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("for X in a b c\ndo echo hi ; done", "TFTFEETTETT"); + } + + public void testFor3Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("for X in a b c ; do\necho hi ; done", "TFTFEETTTETT"); + } + + public void testFor4Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("for X in a b c ; do echo hi\ndone", "TFTFEETTTET"); + } + + public void testCaseCommand() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in ( 1 | 2 ) echo hi ;; 3 ) echo bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase2Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3\nin ( 1 | 2 ) echo hi ;; 3 ) echo bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase3Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in\n( 1 | 2 ) echo hi ;; 3 ) echo bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase4Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in ( 1 | 2 )\necho hi ;; 3 ) echo bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase5Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in ( 1 | 2 ) echo hi\n;; 3 ) echo bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase6Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in ( 1 | 2 ) echo hi ;;\n3 ) echo bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase7Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in ( 1 | 2 ) echo hi ;; 3 )\necho bye ; esac", "TFTTFTFTTETETTETT"); + } + + public void testCase8Command() throws ShellSyntaxException, CompletionException { + doCompletionTest("case 3 in ( 1 | 2 ) echo hi ;; 3 ) echo bye\nesac", "TFTTFTFTTETETTET"); + } + + public void testBadCommand() throws ShellSyntaxException, CompletionException { + doCompletionTest("cpuid hi", "TE"); + } + + public void testBad2Command() throws ShellSyntaxException, CompletionException { + try { + doCompletionTest("if fi ;", "T?"); + } catch (CompletionException ex) { + assertEquals("Cannot find an alias or load a command class for 'fi'", ex.getMessage()); + } + } + private void doCompletionTest(String input, String flags) throws ShellSyntaxException, CompletionException { BjorneInterpreter interpreter = new BjorneInterpreter(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits