Created
February 8, 2017 07:45
-
-
Save yswallow/2d6a3b3aba92c7217226c2a97e324e06 to your computer and use it in GitHub Desktop.
TreeScript1.javaの出力が正しいか確認するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scripts_ans = [ | |
| ['( + 3 8 )', 11], | |
| ['( + 5 ( * 3 7 ) )', 26], | |
| ['3', 3], | |
| ['abc', 'abc'], | |
| ['( call ( fun square ( call square 3 ) ) ( fun x ( * x x ) ) )', 9], | |
| ['( call ( call ( fun x ( fun y ( / ( + x y ) 2 ) ) ) 5 ) 9 )', 7], | |
| ['( == ( + 1 1 ) 2 )', '( fun left ( fun right left ) )'], | |
| ['( == ( + 1 1 ) 0 )', '( fun left ( fun right right ) )'], | |
| ['( call ( call ( == 1 1 ) ( * 3 3 ) ) ( * 5 5 ) )', 9], | |
| ['( call ( call ( == 0 1 ) ( * 3 3 ) ) ( * 5 5 ) )', 25] ] | |
| wrongFlag = false | |
| scripts_ans.each do |script, ans| | |
| kekka = `echo '#{script}' | java TreeScript1` | |
| puts "input: #{script}", kekka | |
| if kekka.each_line.to_a.last.chomp == ans.to_s | |
| puts :correct | |
| else | |
| puts :wrong, "should be #{ans}" | |
| wrongFlag = true | |
| end | |
| puts | |
| end | |
| puts "お前はクビだ" if wrongFlag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment