Skip to content

Commit

Permalink
Introduced tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
flhorizon committed May 30, 2015
1 parent ad56b30 commit b6a7b4f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ IFACESUBD = $(addprefix $(IFACED)/, $(SUBDIRS))
IFACE_ = $(SRC_:.hs=.hi)
IFACE = $(addprefix $(IFACED)/, $(IFACE_))

TESTD := tests
TESTS := tests.rb

RUBY := $(shell which ruby)



all: $(OBJD) $(BIN)

Expand All @@ -48,5 +54,8 @@ fclean: clean

re: fclean all

tests: $(BIN)
( cd $(TESTD) && $(RUBY) $(TESTS) )


.PHONY: all clean fclean re
.PHONY: all clean fclean re tests
52 changes: 52 additions & 0 deletions tests/tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/ruby

argv = ['../mySolver']

tests = [ \
# Basic / mandatory cases
'5 * X^0 + 4 * X^1 = 4 * X^0',
'5 * X^0 + 4 * X^1 = 4 * X^0',
'8 * X^0 - 6 * X^1 + 0 * X^2 - 5.6 * X^3 = 3 * X^0',
'42 = 42',
'42 - 43 * X^0 = 0',

# Deg2 single.
' X^2 - 1 + 4X = 2 X',

# Deg1 neg power
' 5 = X^1',
# Deg1 neg power
' X^2 = 2 X^-1',
# Deg2 neg power
' X = 5 X^-1',

# Deg2 neg power exponential coeff notation
' X - 666.0E-2 X^-1 = -0.0e-1',

# Deg 4 neg power
' X^-5 - X = 0',

# Deg 2 Complex
'X^2 + X + 1 = 0',

# Deg 2 neg power Complex
'X + 1 = -X^-1'\
]

sep = Proc.new do

spaces = Array.new( 80, ' '.bytes.first ).pack('C*')
nl = [0xA].pack('C')
dashes = Array.new( 80, '-'.bytes.first ).pack('C*')

spaces + nl + dashes + nl + spaces
end.call


tests.each do |c|

cmd = argv.+([' \'', c, '\'']).join
puts cmd
system cmd
puts sep
end

0 comments on commit b6a7b4f

Please sign in to comment.