mirror of
https://github.com/samsonjs/csc360-a1-shell.git
synced 2026-03-25 08:45:52 +00:00
Add failing tests for missing wordexp functionality
This commit is contained in:
parent
9ae167ac4a
commit
826b4d5594
1 changed files with 31 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
require "minitest/autorun"
|
||||
require "etc"
|
||||
|
||||
class ShellTest < Minitest::Test
|
||||
TRIVIAL_SHELL_SCRIPT = "#!/bin/sh\ntrue".freeze
|
||||
|
|
@ -57,6 +58,36 @@ class ShellTest < Minitest::Test
|
|||
FileUtils.rm_f("globtest_b.txt")
|
||||
end
|
||||
|
||||
def test_does_not_expand_escaped_dollar
|
||||
assert_equal "$HOME", `#{A1_PATH} -c 'echo \\$HOME'`.chomp
|
||||
end
|
||||
|
||||
def test_expands_brace_expansion
|
||||
assert_equal "a b", `#{A1_PATH} -c 'echo {a,b}'`.chomp
|
||||
end
|
||||
|
||||
def test_expands_command_substitution_backticks
|
||||
assert_equal "hi", %x(#{A1_PATH} -c 'echo `echo hi`').chomp
|
||||
end
|
||||
|
||||
def test_expands_command_substitution_dollar_paren
|
||||
assert_equal "hi", `#{A1_PATH} -c 'echo $(echo hi)'`.chomp
|
||||
end
|
||||
|
||||
def test_expands_arithmetic
|
||||
assert_equal "3", `#{A1_PATH} -c 'echo $((1 + 2))'`.chomp
|
||||
end
|
||||
|
||||
def test_expands_tilde_user
|
||||
user = Etc.getlogin
|
||||
skip "no login user" unless user
|
||||
assert_equal Dir.home(user), `#{A1_PATH} -c 'echo ~#{user}'`.chomp
|
||||
end
|
||||
|
||||
def test_expands_parameter_default_value
|
||||
assert_equal "fallback", `#{A1_PATH} -c 'echo ${A1_UNSET_VAR:-fallback}'`.chomp
|
||||
end
|
||||
|
||||
#################################
|
||||
### Execution and job control ###
|
||||
#################################
|
||||
|
|
|
|||
Loading…
Reference in a new issue