Skip to content

Commit

Permalink
extend suggestion to other files
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Oct 9, 2023
1 parent 442079e commit 64fadf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions examples/password/password_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@ const (

fn test_password_input() {
correct := os.execute(os.join_path(expect_tests_path, 'correct.expect'))
if correct.exit_code != 0 {
assert false, correct.output
}
assert correct.exit_code == 0, correct.output

incorrect := os.execute(os.join_path(expect_tests_path, 'incorrect.expect'))
if incorrect.exit_code != 0 {
assert false, incorrect.output
}
assert incorrect.exit_code == 0, incorrect.output

expected_out := 'Enter your password : '
mut res := os.execute('${os.join_path(expect_tests_path, 'output_from_expect_arg.expect')} "${expected_out}"')
assert res.exit_code == 0
assert res.exit_code == 0, res.output

not_exptectd_out := 'Enter your passwords : '
res = os.execute('${os.join_path(expect_tests_path, 'output_from_expect_arg.expect')} "${not_exptectd_out}"')
assert res.exit_code == 1
assert res.exit_code == 1, res.output
}
4 changes: 2 additions & 2 deletions examples/readline/readline_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ fn test_password_input() {
send_a := 'a'
expect_a := 'got 97' // readline output for `a`
a_res := os.execute('${os.join_path(expect_tests_path, 'readline_from_expect_arg.expect')} ${send_a} "${expect_a}"')
assert a_res.exit_code == 0
assert a_res.exit_code == 0, a_res.output

send_b := 'b'
b_res := os.execute('${os.join_path(expect_tests_path, 'readline_from_expect_arg.expect')} ${send_b} "${expect_a}"')
assert b_res.exit_code == 1
assert b_res.exit_code == 1, b_res.output
assert b_res.output.contains('got 98')
}

0 comments on commit 64fadf2

Please sign in to comment.