mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Workaround for Crystal compiler bug
See: https://github.com/crystal-lang/crystal/issues/4225 If there are no concrete implementations of a class, an "undefined method" error is given for abstract methods.
This commit is contained in:
parent
c77a85c97a
commit
df36331132
3 changed files with 24 additions and 1 deletions
22
src/spectator/dummy_example.cr
Normal file
22
src/spectator/dummy_example.cr
Normal file
|
@ -0,0 +1,22 @@
|
|||
require "./runnable_example"
|
||||
|
||||
module Spectator
|
||||
# Example that does nothing.
|
||||
# This is to workaround a Crystal compiler bug.
|
||||
# See: [Issue 4225](https://github.com/crystal-lang/crystal/issues/4225)
|
||||
# If there are no concrete implementations of an abstract class,
|
||||
# the compiler gives an error.
|
||||
# The error indicates an abstract method is undefined.
|
||||
# This class shouldn't be used, it's just to trick the compiler.
|
||||
private class DummyExample < RunnableExample
|
||||
# Dummy description.
|
||||
def what
|
||||
"DUMMY"
|
||||
end
|
||||
|
||||
# Dummy run that does nothing.
|
||||
def run_instance
|
||||
# ...
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,6 +16,7 @@ require "./example_component"
|
|||
require "./example"
|
||||
require "./runnable_example"
|
||||
require "./pending_example"
|
||||
require "./dummy_example"
|
||||
|
||||
require "./example_hooks"
|
||||
require "./example_group"
|
||||
|
|
|
@ -4,7 +4,7 @@ module Spectator
|
|||
# Common base for all examples that can be run.
|
||||
# This class includes all the logic for running example hooks,
|
||||
# the example code, and capturing a result.
|
||||
# Sub-classes need to implement the `#run_instance` method.
|
||||
# Sub-classes need to implement the `#what` and `#run_instance` methods.
|
||||
abstract class RunnableExample < Example
|
||||
# Runs the example, hooks, and captures the result
|
||||
# and translates to a usable result.
|
||||
|
|
Loading…
Reference in a new issue