Skip to content
Browse files

Add tests

  • Loading branch information...
1 parent d859ba5 commit ac47a821fae3569d9919feb55b545c9a2a004f10 @lsegal committed Jan 24, 2011
Showing with 18 additions and 0 deletions.
  1. +4 −0 Rakefile
  2. +14 −0 test/test_ripper.rb
View
4 Rakefile
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require 'rake/testtask'
WINDOWS = (PLATFORM =~ /win32|cygwin/ ? true : false) rescue false
SUDO = WINDOWS ? '' : 'sudo'
@@ -20,3 +21,6 @@ desc 'Build the extension'
task :build do
sh "cd ext && ruby extconf.rb && make clean && make"
end
+
+Rake::TestTask.new
+
View
14 test/test_ripper.rb
@@ -0,0 +1,14 @@
+require "test/unit"
+require File.dirname(__FILE__) + '/../lib/ripper'
+
+class TestRipper < Test::Unit::TestCase
+ def test_ripper
+ sexp = Ripper.sexp("module Foo; def v=(value) value += 1 end end")
+ assert_equal sexp, [:program,
+ [[:module, [:const_ref, [:@const, "Foo", [1, 7]]], [:bodystmt, [[:void_stmt],
+ [:def, [:@ident, "v=", [1, 16]], [:paren, [:params, [[:@ident, "value", [1, 19]]],
+ nil, nil, nil, nil]], [:bodystmt, [[:opassign, [:var_field, [:@ident, "value",
+ [1, 26]]], [:@op, "+=", [1, 32]], [:@int, "1", [1, 35]]]], nil, nil, nil]]],
+ nil, nil, nil]]]]
+ end
+end

0 comments on commit ac47a82

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