2018-11-09 18:20:30 +00:00
|
|
|
# Example system to test that doubles as a spy.
|
|
|
|
# This class tracks calls made to it.
|
|
|
|
class SpySUT
|
2019-01-24 04:02:32 +00:00
|
|
|
{% for item in [
|
2019-01-24 04:11:01 +00:00
|
|
|
{"==", "eq"},
|
|
|
|
{"!=", "ne"},
|
|
|
|
{"<", "lt"},
|
|
|
|
{"<=", "le"},
|
|
|
|
{">", "gt"},
|
|
|
|
{">=", "ge"},
|
|
|
|
{"===", "case_eq"},
|
|
|
|
{"=~", "match"},
|
2019-01-25 20:12:34 +00:00
|
|
|
{"includes?", "includes"},
|
2019-01-24 04:11:01 +00:00
|
|
|
] %}
|
2019-01-24 04:02:32 +00:00
|
|
|
{% operator = item[0].id %}
|
|
|
|
{% name = item[1].id %}
|
2018-11-09 18:20:30 +00:00
|
|
|
|
2019-01-24 04:02:32 +00:00
|
|
|
# Number of times the `#{{operator}}` method was called.
|
|
|
|
getter {{name}}_call_count = 0
|
2019-01-19 20:50:57 +00:00
|
|
|
|
2019-01-24 04:02:32 +00:00
|
|
|
# Returns true and increments `#{{name}}_call_count`.
|
|
|
|
def {{operator}}(other : T) forall T
|
|
|
|
@{{name}}_call_count += 1
|
2019-01-19 20:50:57 +00:00
|
|
|
true
|
|
|
|
end
|
2019-01-19 21:49:13 +00:00
|
|
|
|
2019-01-24 04:02:32 +00:00
|
|
|
{% end %}
|
2018-11-09 18:20:30 +00:00
|
|
|
end
|