Skip to content
Browse files

Let there be LET tests.

  • Loading branch information...
1 parent 35cc605 commit 5066595ca6df8eac80dfc565665fce0613832fa0 @therealadam committed May 11, 2009
Showing with 22 additions and 10 deletions.
  1. +14 −6 features/let.feature
  2. +8 −4 features/step_definitions/basick_steps.rb
View
20 features/let.feature
@@ -1,6 +1,14 @@
-Given a program
- """
- LET a := 4 + 4
- LET b := 5 + 5
- """
-Then environment is "{'a' => 8, 'b' => 10}"
+Feature: LET
+ Programs with assignment, while hard to debug, are easier to write for many
+ people. Therefore, Basick should support assignment.
+
+ Scenario: simple let
+ Given a program
+ """
+ LET a := 4 + 4
+ LET b := 5 + 5
+ """
+ Then the program should parse
+ And the value of "a" is "8"
+ And the value of "b" is "10"
+
View
12 features/step_definitions/basick_steps.rb
@@ -9,18 +9,22 @@
PrintNode.output = @output
@parser = LanguageParser.new
+ @result = @parser.parse(@source)
+ @env = @result.eval({})
end
Then /^the program should parse$/ do
- result = @parser.parse(@source)
- result.eval({})
- unless result
+ unless @result
puts 'ERROR:'
puts @parser.terminal_failures.join("\n")
end
- assert result
+ assert @result
end
Then /^the output is '(.*)'$/ do |output|
assert_equal output, @output.string
end
+
+Then /^the value of "([^\"]*)" is "([^\"]*)"$/ do |key, value|
+ assert_equal value, @env[key].to_s
+end

0 comments on commit 5066595

Please sign in to comment.
Something went wrong with that request. Please try again.