Skip to content

Keep timestamps off the stack #41

Open
@Kacarott

Description

@Kacarott

(I am not sure why this this wasn't raised as an issue, and have just remembered it now, so moving it to a more appropriate place).
Currently, both it#{ and describe#{ leave a timestamp on the stack, used for reporting the runtime of the users code. This is essentially an implementation detail, but the issue is that it can interfere with user code. Consider this:

"tests" describe#{
   <some-large-data-structure>
   "should work in context A" it#{
     dup run-test-a
   }#
  
   "should work in context B" it#{
     dup run-test-b
   }#
  drop
}#

This seems fairly regular code, however without the author realising it, it will be calling both run-test words with some arbitrary number, instead of the expected data structure!

There is really no reason for the timestamps to be left on the stack like this, and it is simple to fix. Simply scan the relevant block, and run the resulting quotation inside dip such that the timestamp is moved to the retain stack. See this for a simple proof of concept.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions