Class: Gobstones::Checker
- Inherits:
-
Mumukit::Metatest::Checker
- Object
- Mumukit::Metatest::Checker
- Gobstones::Checker
show all
- Includes:
- WithRenderer
- Defined in:
- lib/checker.rb
Instance Method Summary
collapse
#render_error_output, #render_success_output
Constructor Details
#initialize(options) ⇒ Checker
Returns a new instance of Checker.
5
6
7
|
# File 'lib/checker.rb', line 5
def initialize(options)
@options = options
end
|
Instance Method Details
#check_error(output, expected) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/checker.rb', line 35
def check_error(output, expected)
status = output[:status]
result = output[:result]
return if is_expected_timeout(result)
fail_with status: :check_error_failed_expected_boom,
result: {
initial: result[:initialBoard],
expected: :boom,
final: result[:finalBoard]
} if status.passed?
reason_code = convert_known_reason_code result[:finalBoardError][:reason][:code]
fail_with status: :check_error_failed_another_reason,
result: {
reason: result[:finalBoardError],
expected_code: expected
} if reason_code != expected
end
|
#check_final_board(output, expected) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/checker.rb', line 9
def check_final_board(output, expected)
status = output[:status]
result = output[:result]
return if is_expected_timeout(result)
assert_not_boom status, result
expected_board = result[:extraBoard]
actual_board = result[:finalBoard]
boards_match = board_json(expected_board).eql? board_json(actual_board)
= expected_board[:head].eql?(actual_board[:head]) || !@options[:check_head_position]
if !boards_match || !
status = boards_match && ! ?
:check_final_board_failed_different_headers :
:check_final_board_failed_different_boards
fail_with status: status,
result: {
initial: result[:initialBoard],
expected: expected_board,
actual: actual_board
}
end
end
|
#check_return(output, expected) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/checker.rb', line 56
def check_return(output, expected)
status = output[:status]
result = output[:result]
assert_not_boom status, result
return_value = result[:finalBoard][:returnValue]
fail_with status: :check_return_failed_no_return,
result: {
initial: result[:initialBoard],
expected_value: expected
} if return_value.nil?
final_value = adapt_value return_value
final_expected_value = expected
if return_value[:type] == 'Number'
final_value = final_value.to_s
final_expected_value = final_expected_value.to_s
end
fail_with status: :check_return_failed_different_values,
result: {
initial: result[:initialBoard],
expected_value: expected,
actual_value: final_value
} if final_value != final_expected_value
end
|