Skip to content

Instantly share code, notes, and snippets.

@Vaguery
Created December 2, 2010 15:01
Show Gist options
  • Select an option

  • Save Vaguery/725482 to your computer and use it in GitHub Desktop.

Select an option

Save Vaguery/725482 to your computer and use it in GitHub Desktop.
Feature: random Pile script generator
In order to get sample arbitrary Pile solutions to a target problem
As a symbolic regression modeler
I want to be able to compose random Pile scripts, sampled from a set of tokens
Scenario: sample available tokens uniformly
When I generate 10000 random Pile scripts, each with 20 tokens
And the available tokens are ["a", "b", "c"]
Then the tokens should appear (on average) with equal frequency
And all possible pairs should appear (on average) with equal frequency
Scenario: random constants use "k" as a placeholder
When I generate 10000 random Pile scripts, each with 20 tokens
And the available tokens are ["k"]
Then every script should contain 20 floating-point numbers
And every generated number should have at most 3 digits after the decimal
And every generated number should be within [-20.000,20.000]
Scenario: should be able to generate scripts of a given size
When I generate 10 random Pile scripts, each with 100 tokens
Given the available tokens are ["foo", "bar", "baz", "qux", "hah"]
Then every script should contain 100 tokens
And every script should contain 399 characters
And every script should contain 99 spaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment