Retired

Learning Shell: Count to 30 (retired)

106PG1
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • kazk Avatar

    The test doesn't match the description.

    echo "9 30 28 1 3 12 8 4 16 29" # valid
    # it's also valid even if the solution prints 1..31
    

    Also, the delimiter is not specified. Most solutions assumes \n.


    Keeping it very basic to try out test cases.

    The following can be used to test if the output is exactly 1..30.

    describe "Loop" do
      it "Tests" do
        expect(run_shell.split("\n").map {|x| x.to_i}).to eq((1..30).to_a)
      end
    end
    

    You can also do random tests if you're willing to change the kata to print to arbitrary maximum.

    it "Random" do
      10.times { # Print numbers 1..n
        n = rand(1..30)
        expect((run_shell args: [n]).split("\n").map {|x| x.to_i}).to eq((1..n).to_a)
      }
    end
    
    • lynxlynxlynx Avatar

      IMHO it's enough to fix the test to check for presence of all the numbers. Regardless of delimiter or order, since the description specify none (and simple is better for an entry kata like this).

  • JohanWiltink Avatar

    using a loop

    This requirement is not tested.