bash icon indicating copy to clipboard operation
bash copied to clipboard

Add `-n` test to reverse-string ?

Open glennj opened this issue 1 year ago • 2 comments

Given that the builtin echo command cannot output the string "-n" (ref Why is printf better than echo?), we could amp up the difficulty of reverse-string by adding another diabolical test:

@test "echo -n" {
  [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  run bash reverse_string.sh 'n-'

  assert_success
  assert_output -- '-n'
}

This will force the student to learn about a fairly nasty echo edge case.

On the other hand, reverse-string is currently an easy exercise with difficulty 1, and adding this test is likely to break a large proportion of existing solutions.

glennj avatar Nov 18 '24 14:11 glennj

Printing -n is a fun challenge, but it's not especially relevant to this exercise. In theory, that could be tacked onto any other exercise that allows arbitrary strings as the output. I would suggest passing.

IsaacG avatar Nov 18 '24 17:11 IsaacG

We could bring this up in an automated feedback, rather than driving it through tests.

kotp avatar Nov 18 '24 18:11 kotp