From 50d1f692300a1c7e5a13c85e4e3202d37aae5f44 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 15 Jan 2021 23:15:07 -0700 Subject: [PATCH] Don't cache the block return value Let the matcher handle this if it needs to. --- src/spectator/block.cr | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/spectator/block.cr b/src/spectator/block.cr index 5deb82c..135c537 100644 --- a/src/spectator/block.cr +++ b/src/spectator/block.cr @@ -1,6 +1,5 @@ require "./expression" require "./label" -require "./lazy" module Spectator # Represents a block from a test. @@ -9,9 +8,6 @@ module Spectator # The label should be a string recognizable by the user, # or nil if one isn't available. class Block(T) < Expression(T) - # Cached value returned from the block. - @value = Lazy(T).new - # Creates the block expression from a proc. # The *proc* will be called to evaluate the value of the expression. # The *label* is usually the Crystal code for the *proc*. @@ -28,18 +24,10 @@ module Spectator super(label) end - # Retrieves the value of the block expression. - # This will be the return value of the block. - # The block is lazily evaluated and the value retrieved only once. - # Afterwards, the value is cached and returned by successive calls to this method. - def value - @value.get { call } - end - # Evaluates the block and returns the value from it. # This method _does not_ cache the resulting value like `#value` does. # Successive calls to this method may return different values. - def call : T + def value : T @block.call end end