mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Docs
This commit is contained in:
parent
5dfc60d4cd
commit
6c98d7107c
3 changed files with 16 additions and 4 deletions
|
@ -1,14 +1,19 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
|
# Equals and matches everything.
|
||||||
|
# All comparison methods will always return true.
|
||||||
struct Anything
|
struct Anything
|
||||||
def ==(other)
|
# Returns true for equality.
|
||||||
|
def ==(_other)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def ===(other)
|
# Returns true for case equality.
|
||||||
|
def ===(_other)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def =~(other)
|
# Returns true for matching.
|
||||||
|
def =~(_other)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,17 @@
|
||||||
# This type is intentionally outside the `Spectator` module.
|
# This type is intentionally outside the `Spectator` module.
|
||||||
# The reason for this is to prevent name collision when using the DSL to define a spec.
|
# The reason for this is to prevent name collision when using the DSL to define a spec.
|
||||||
abstract class SpectatorContext
|
abstract class SpectatorContext
|
||||||
|
# Produces a dummy string to represent the context as a string.
|
||||||
|
# This prevents the default behavior, which normally stringifies instance variables.
|
||||||
|
# Due to the sheer amount of types Spectator can create
|
||||||
|
# and that the Crystal compiler instantiates a `#to_s` and/or `#inspect` for each of those types,
|
||||||
|
# an explosion in method instances can be created.
|
||||||
|
# The compile time is drastically reduced by using a dummy string instead.
|
||||||
def to_s(io)
|
def to_s(io)
|
||||||
io << "Context"
|
io << "Context"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ditto:
|
||||||
def inspect(io)
|
def inspect(io)
|
||||||
io << "Context<"
|
io << "Context<"
|
||||||
io << self.class
|
io << self.class
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "json"
|
require "json"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Define the file and line number something originated from.
|
# Defines the file and line numbers something originated from.
|
||||||
struct Source
|
struct Source
|
||||||
# Absolute file path.
|
# Absolute file path.
|
||||||
getter file : String
|
getter file : String
|
||||||
|
|
Loading…
Reference in a new issue