Skip to content

Commit

Permalink
Add simple tests for accepter.rl
Browse files Browse the repository at this point in the history
  • Loading branch information
nelstrom committed Aug 2, 2013
1 parent c8993bf commit c2db5a2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
12 changes: 10 additions & 2 deletions Rakefile
@@ -1,8 +1,10 @@
gem 'rake'
require 'rake/testtask'
require 'rake/clean'
CLEAN.include FileList['lib/*.rb', 'lib/*.dot']

desc "Compile each .rl file to .rb"
task :compile do
task :ragel do
FileList.new('lib/*.rl').each do |file|
system "ragel -R #{file}"
end
Expand All @@ -15,4 +17,10 @@ task :visualize do
end
end

task :default => :compile
Rake::TestTask.new(:test => :ragel) do |t|
t.libs << 'test'
t.test_files = FileList['test/*_test.rb']
t.verbose = false
end

task :default => :test
5 changes: 2 additions & 3 deletions lib/accepter.rl
Expand Up @@ -22,6 +22,8 @@

class VimParser

attr_accessor :data

def initialize()
%% write data;
end
Expand All @@ -41,6 +43,3 @@ class VimParser

end

parser = VimParser.new
puts parser.accept?("helihello\e")
puts parser.accept?("viw")
17 changes: 17 additions & 0 deletions test/accepter_test.rb
@@ -0,0 +1,17 @@
gem "minitest"
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/accepter'

describe VimParser do

it 'accepts motions, switches, and insertions' do
assert VimParser.new.accept?("hellohello\e")
end

it 'rejects everything else' do
refute VimParser.new.accept?("viw")
end

end

0 comments on commit c2db5a2

Please sign in to comment.