Skip to content

Commit 6562ae9

Browse files
committed
Slightly improve templates
1 parent d17f366 commit 6562ae9

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

bin/generator-utils/templates.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,19 @@ EOT
4545
# loop through each object
4646
jq -c '.[]' <<<"$cases" | while read -r case; do
4747
desc=$(echo "$case" | jq '.description' | tr '[:upper:]' '[:lower:]' | tr ' ' '_' | tr -cd '[:alnum:]_' | sed 's/^/test_/')
48-
input=$(echo "$case" | jq '.input')
49-
expected=$(echo "$case" | jq '.expected')
48+
input=$(echo "$case" | jq -c '.input')
49+
expected=$(echo "$case" | jq -c '.expected')
5050

5151
# append each test fn to the test file
5252
cat <<EOT >>"$test_file"
5353
#[test] $([[ "$first_iteration" == false ]] && printf "\n#[ignore]")
5454
fn ${desc}() {
55-
/*
56-
Input:
57-
${input}
5855
59-
Expected output:
60-
${expected}
61-
*/
56+
let input = ${input};
57+
let expected = ${expected};
6258
6359
// TODO: Add assertion
64-
assert_eq!(1, 1)
60+
assert_eq!(input, expected)
6561
}
6662
6763
EOT
@@ -77,7 +73,7 @@ function create_lib_rs_template() {
7773
local slug=$2
7874
cat <<EOT >"${exercise_dir}/src/lib.rs"
7975
fn $(dash_to_underscore "$slug")() {
80-
unimplemented!("implement "$slug" exercise")
76+
unimplemented!("implement ${slug} exercise")
8177
}
8278
EOT
8379
message "success" "Stub file for lib.rs has been created!"

0 commit comments

Comments
 (0)