Skip to content

Commit

Permalink
grains error message and test cases updated (#67)
Browse files Browse the repository at this point in the history
* grains error message and test cases updated

* grains - Typo fix in exercise instruction

Co-authored-by: András B Nagy <[email protected]>

* grains instruction rollback for clean movement

* grains exercise docs improvement

Co-authored-by: András B Nagy <[email protected]>

* Update tests.toml

---------

Co-authored-by: András B Nagy <[email protected]>
  • Loading branch information
GroophyLifefor and BNAndras authored Sep 21, 2024
1 parent d6a09fa commit 74167c6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions exercises/practice/grains/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Independent of other languages

However, the king ran out of grains to give the servant after day 31 since 1,073,741,824 grains is approximately 54 metric tons.
As a 32-bit language, Batch can't represent the number of grains past this point.
6 changes: 3 additions & 3 deletions exercises/practice/grains/.meta/Example.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ setlocal EnableDelayedExpansion
set "input=%~1"

if %input% LSS 1 (
echo square must be between 1 and 64
echo square must be between 1 and 31
exit /b 1
)

if %input% GTR 64 (
echo square must be between 1 and 64
if %input% GTR 31 (
echo square must be between 1 and 31
exit /b 1
)

Expand Down
5 changes: 5 additions & 0 deletions exercises/practice/grains/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ description = "returns the number of grains on the square -> grains on square 16

[acd81b46-c2ad-4951-b848-80d15ed5a04f]
description = "returns the number of grains on the square -> grains on square 32"
include = false
comment = "Batch is 32-bit so square 31 is maximum possible"

[c73b470a-5efb-4d53-9ac6-c5f6487f227b]
description = "returns the number of grains on the square -> grains on square 64"
include = false
comment = "Batch is 32-bit so square 31 is maximum possible"

[1d47d832-3e85-4974-9466-5bd35af484e3]
description = "returns the number of grains on the square -> square 0 is invalid"
Expand All @@ -39,6 +42,8 @@ description = "returns the number of grains on the square -> negative square is

[a95e4374-f32c-45a7-a10d-ffec475c012f]
description = "returns the number of grains on the square -> square greater than 64 is invalid"
include = false
comment = "Batch is 32-bit so the test description, input, and expected value all were changed"

[6eb07385-3659-4b45-a6be-9dc474222750]
description = "returns the total number of grains on the board"
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/grains/GrainsTest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ if "%1" == "test-runner" (
set "if_failed=Test failed: grains on square 31."
CALL :Assert "31"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: square 0 is invalid."
CALL :Assert "0"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: negative square is invalid."
CALL :Assert "-1"

set "expected=square must be between 1 and 64"
set "expected=square must be between 1 and 31"
set "if_success=Test passed"
set "if_failed=Test failed: square greater than 64 is invalid."
set "if_failed=Test failed: square greater than 31 is invalid."
CALL :Assert "65"

REM --------------------
Expand Down

0 comments on commit 74167c6

Please sign in to comment.