diff --git a/Rakefile b/Rakefile index 2199694..73e99a0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,16 @@ +require 'rake/classic_namespace' +require 'rake/clean' + +CLEAN.include('gen_*.pir') +CLEAN.include('*/gen_*.pir') +CLEAN.include('*/*/gen_*.pir') +CLEAN.include('Test.pir') +CLEAN.include('build.yaml') +CLEAN.include('*.c') +CLEAN.include('*.o') +CLOBBER.include('cardinal') +CLOBBER.include('*.pbc') + DEBUG = ENV['debug'] || false ALTERNATIVE_RUBY = ENV['test_with'] || false CONFIG = {} @@ -75,11 +88,14 @@ def test(file, name="") end else file "t/#{pir_file}" => [:config, "t/#{file}", "src/gen_actions.pir", "src/gen_grammar.pir"] do + unless File.exists?('cardinal.pbc') + Task['cardinal.pbc'].invoke + end parrot("t/#{file}", "t/#{pir_file}", "cardinal.pbc", "pir") end puts "named #{name}" if DEBUG - task name => [:config, "t/#{pir_file}", "cardinal.pbc", "Test.pir"] do - run_test pir_file, name + task name => [:config, "t/#{pir_file}", "cardinal.pbc", "Test.pir"] do |t| + run_test pir_file, "#{t.scope.join(':')}:#{name}" end end end @@ -153,10 +169,11 @@ def run_test(file,name="") result = "Complete failure... no plan given" $failures += 1 end - puts "Running test #{name} #{result}" + puts "Running #{name} #{result}" end end +desc "Determine configuration information" task :config => "build.yaml" do require 'yaml' File.open("build.yaml","r") do |f| @@ -187,6 +204,7 @@ file "build.yaml" do end end +desc "Make the cardinal binary." file "cardinal" => [:config, "cardinal.pbc"] do make_exe("cardinal.pbc") end @@ -292,6 +310,7 @@ namespace :test do |ns| test "array/values_at.t" test "array/warray.t" + desc "Run tests on Array." task :all => [:array, :assign, :at, :clear, :collect, :compact, :concat, :delete, :empty, :equals, :fetch, :fill, :first, :flatten, :grep, :include, :index, :insert, :intersection, :join, :mathop, :nitems, :pop, :push, :reject, :replace, :reverse, :shift, :slice, :sort, :to_s, :uniq, :values_at, :warray] end @@ -300,6 +319,7 @@ namespace :test do |ns| test "file/file.t" test "file/stat.t" + desc "Run tests on File." task :all => [:dir, :file, :stat] end @@ -307,6 +327,7 @@ namespace :test do |ns| test "hash/hash.t" test "hash/exists.t" + desc "Run tests on Hash." task :all => [:hash, :exists] end @@ -315,6 +336,7 @@ namespace :test do |ns| test "integer/times.t" test "integer/cmp.t" + desc "Run tests on Integer." task :all => [:integer, :times, :cmp] end @@ -323,12 +345,14 @@ namespace :test do |ns| test "kernel/open.t" test "kernel/sprintf.t" + desc "Run tests on Kernel." task :all => [:exit, :open, :sprintf] end namespace :math do test "math/functions.t" + desc "Run tests on Math." task :all => [:functions] end @@ -342,6 +366,7 @@ namespace :test do |ns| test "range/to_s.t" test "range/tofrom-variants.t" + desc "Run tests on Range." task :all => [:each, :infixexclusive, :infixinclusive, :membershipvariants, :new, :to_a, :to_s, :tofromvariants] end @@ -362,10 +387,14 @@ namespace :test do |ns| test "string/reverse.t" test "string/upcase.t" + desc "Run tests on String." task :all => [:add, :block, :capitalize, :chops, :cmp, :concat, :downcase, :empty, :eq, :mult, :new, :quote, :random_access, :reverse, :upcase] end - task :basic => [:sanity, :stmts, :functions, :return, :indexed, :opcmp, :loops, :class, :test, :regex, :slurpy, :gather, :other, :alias, :assignment, :blocks, :constants, :continuation, :freeze, :gc, :nil, :proc, :range, :splat, :time, :yield, :zip] + desc "Run basic tests." + task :basic => [:sanity, :stmts, :functions, :return, :indexed, :opcmp, :loops, :class, :test, :regex, :slurpy, :gather, :other, :alias, :assignment, :bool, :blocks, :constants, :continuation, :freeze, :gc, :nil, :proc, :range, :splat, :time, :yield, :zip] + + desc "Run the entire test suite." task :all => [:basic, "array:all", "file:all", "hash:all", "integer:all", "kernel:all", "math:all", "range:all", "string:all"] do dur_seconds = Time.now.to_i - $start.to_i dur_minutes = 0 @@ -426,6 +455,7 @@ namespace :test do |ns| puts " -- CLEAN FOR COMMIT --" if clean? end + desc "Run test:all *and* produce stats about known issues." task :stats => [:all] do $pl = $issue_counts.size > 1 unless $issue_counts.empty? diff --git a/build/Makefile.in b/build/Makefile.in index babbd44..97669c8 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -48,14 +48,15 @@ BUILTINS_PIR = \ src/builtins/cmp.pir \ src/builtins/op.pir \ src/classes/Object.pir \ + src/classes/Exception.pir \ src/classes/NilClass.pir \ src/classes/String.pir \ src/classes/Integer.pir \ src/classes/Array.pir \ src/classes/Hash.pir \ - src/classes/Any.pir \ src/classes/Range.pir \ - src/classes/Bool.pir \ + src/classes/TrueClass.pir \ + src/classes/FalseClass.pir \ src/classes/Kernel.pir \ src/classes/Time.pir \ src/classes/Math.pir \ @@ -132,13 +133,13 @@ help: @echo "" test: all - $(PERL) t/harness + rake test:all arraytest: all - $(PERL) t/harness --tests-from-dir=array + rake test:array:all hashtest: all - $(PERL) t/harness --tests-from-dir=hash + rake test:hash:all # this target has nothing to do testclean: diff --git a/src/builtins/cmp.pir b/src/builtins/cmp.pir index e458207..a201aa3 100644 --- a/src/builtins/cmp.pir +++ b/src/builtins/cmp.pir @@ -45,20 +45,35 @@ Swiped from Rakudo. .return ($P0) .end -.sub 'infix:==' :multi(TrueClass,FalseClass) +.sub 'infix:==' :multi(TrueClass,_) .param pmc a .param pmc b $P0 = get_hll_global 'false' .return ($P0) .end -.sub 'infix:==' :multi(FalseClass,TrueClass) +.sub 'infix:==' :multi(FalseClass,_) .param pmc a .param pmc b $P0 = get_hll_global 'false' .return ($P0) .end +.sub 'infix:==' :multi(_,TrueClass) + .param pmc a + .param pmc b + $P0 = get_hll_global 'false' + .return ($P0) +.end + +.sub 'infix:==' :multi(_,FalseClass) + .param pmc a + .param pmc b + $P0 = get_hll_global 'false' + .return ($P0) +.end + + .sub 'infix:==' :multi(Integer,Integer) .param pmc a .param pmc b diff --git a/src/classes/GC.pir b/src/classes/GC.pir index 1e39551..93a2c47 100644 --- a/src/classes/GC.pir +++ b/src/classes/GC.pir @@ -54,12 +54,10 @@ Perform initializations and create the GC class $P1 = 1 setattribute self, '$!disabled', $P1 collectoff - $P0 = new 'CardinalString' - $P0 = 'false' + $P0 = get_hll_global 'false' .return ($P0) already_disabled: - $P0 = new 'CardinalString' - $P0 = 'true' + $P0 = get_hll_global 'true' .return ($P0) .end @@ -68,16 +66,14 @@ Perform initializations and create the GC class if $P0 == 1 goto enable goto already_enabled already_enabled: - $P0 = new 'CardinalString' - $P0 = 'false' + $P0 = get_hll_global 'false' .return ($P0) enable: $P1 = new 'CardinalInteger' $P1 = 0 setattribute self, '$!disabled', $P1 collecton - $P0 = new 'CardinalString' - $P0 = 'true' + $P0 = get_hll_global 'true' .return ($P0) .end diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index a018208..9185e35 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -414,7 +414,7 @@ token literal { } token float { - '-'? \d* '.' \d+ + '-'? \d+ '.' \d+ {*} } @@ -542,7 +542,6 @@ proto 'infix:/' is equiv('infix:*') { ... } proto 'infix:%' is equiv('infix:*') is pirop('mod') { ... } -# #proto 'prefix:+' is tighter('infix:*') { ... } #proto 'prefix:-' is equiv('prefix:+') { ... } #proto 'prefix:!' is equiv('prefix:+') { ... } diff --git a/t/bool.t b/t/bool.t index 9c7d9d9..6cf593e 100644 --- a/t/bool.t +++ b/t/bool.t @@ -1,8 +1,15 @@ require "Test" include Test -plan 3 +plan 10 is true, true, "true == true" is false, false, "false == false" isnt true, false, "true != false" +isnt true, 1, "true != 1" +isnt true, 0, "true != 0" +isnt false, 0, "false != 0" +isnt -1, false, "-1 != false" +isnt -1, true, "-1 != false" +isnt "", false, "empty string isn't false" +isnt "", true, "empty string isn't true"