Skip to content

Commit

Permalink
Set up Blueprint stdlib tests through rake
Browse files Browse the repository at this point in the history
We implemented the standard library's tests in Blueprint, but we
should still be running them when we run rake (for CI, in particular).

Also implement a blueprint executable for running files.
  • Loading branch information
hrs committed Oct 3, 2015
1 parent 3f9966e commit 8347625
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 173 deletions.
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task default: :spec
task :standard_library_tests do
system("bin/blueprint spec/*-tests.blu") || exit(1)
end

task default: [:spec, :standard_library_tests]
11 changes: 11 additions & 0 deletions bin/blueprint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby

require_relative "../lib/blueprint"

input = ""

while line = gets
input << line
end

Blueprint::Interpreter.new.eval(input)
4 changes: 2 additions & 2 deletions lib/standard-library.blu
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
""
args))

(define dolist map)

(define (even? n)
(== (% n 2) 0))

Expand Down Expand Up @@ -45,6 +43,8 @@
(cons (f (first seq))
(map f (rest seq)))))

(define dolist map)

(define (not value)
(if value
false
Expand Down
8 changes: 2 additions & 6 deletions spec/test-framework.blu → lib/test-framework.blu
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
(if (== a b)
(display ".")
(prog
(display "F\n")
(display a)
(display " and ")
(display b)
(display " aren't equal!\n")
(display (concatenate "F\n" a " and " b " aren't equal!\n"))
(exit 1))))

(define (deftest docstring test)
Expand All @@ -21,5 +17,5 @@

(define (run-tests)
(prog
(map (lambda (test) (test)) pending-tests)
(dolist (lambda (test) (test)) pending-tests)
(display "\nDone. Lookin' fine!\n")))
7 changes: 6 additions & 1 deletion spec/standard-library-tests.blu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(load "test-framework.blu")
(load "lib/test-framework.blu")

(deftest
"and returns true if all arguments are truthy"
Expand All @@ -10,6 +10,11 @@
'(assert-equal (and 1 false "foo")
false))

(deftest
"concatenate appends its arguments together into a string"
'(assert-equal (concatenate 1 " foo " '(1 2))
"1 foo (1 2)"))

(deftest
"even? returns true if a number is even"
'(assert-equal (even? 4)
Expand Down
163 changes: 0 additions & 163 deletions spec/standard_library_spec.rb

This file was deleted.

0 comments on commit 8347625

Please sign in to comment.