Skip to content

Add -n test to reverse-string ? #711

@glennj

Description

@glennj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions