Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

release 0.0.4

  • Loading branch information...
commit 95c64c1336231827086ab3d800da77d276b77769 1 parent 2656831
@mwotton authored
View
4 HISTORY.markdown
@@ -11,3 +11,7 @@
## 0.0.3 2009-08-29
* first working inline version (ints only, jhc only, very limited)
+
+## 0.0.4 2009-09-01
+
+* floats, strings, nils, booleans now working.
View
2  hubris.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{hubris}
- s.version = "0.0.3"
+ s.version = "0.0.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Mark Wotton", "James Britt", "Josh Price"]
View
4 lib/RubyMap.chs
@@ -10,6 +10,8 @@ import Foreign.Ptr
import Foreign.C.Types
import Foreign.C.String
import System.IO.Unsafe (unsafePerformIO)
+import Foreign.Marshal.Array
+
-- import PackedString
{# context lib="rshim" #}
{# enum RubyType {} deriving (Eq, Show) #} -- maybe Ord?
@@ -43,7 +45,7 @@ data RValue = T_NIL
| T_STRING String
-- | T_REGEXP
-- the array needs to be managed by ruby
--- | T_ARRAY (CArray Word RValue)
+ | T_ARRAY (Array Word RValue)A
| T_FIXNUM Int --fixme, probably
-- the hash needs to be managed by ruby
| T_HASH Int -- definitely FIXME - native ruby hashes, or going to translitrate?
View
94 spec/hubris_spec.rb
@@ -1,94 +0,0 @@
-require File.dirname(__FILE__) + '/spec_helper.rb'
-
-# just want to check it's actually possible to load a library dynamically
-describe "dlload" do
- it "can actually build and load a C level dylib stupidly" do
- system "cd sample; make"
- `cd sample; ruby hsload.rb`.chomp.should eql("144")
- end
-end
-
-class Target
- include Hubris
- def foo
- 14
- end
-end
-
-
-describe "Target" do
- it "can whine like a little baby when you pass it bad haskell" do
- t=Target.new
- lambda{ t.inline("broken _ = (1 + \"a string\")")}.should raise_error(SyntaxError)
- end
-
- it "can ignore a comment" do
- t=Target.new
- lambda {t.inline("--blah blah blah
-{- another silly comment -}")}.should_not raise_error
- end
-
- it "can sing like a golden bird when you treat it right, aw yeah" do
- t=Target.new
- lambda { t.inline("working _ = T_FIXNUM (1+2)") }.should_not raise_error
- end
-
-
- it "can double an int in Haskell-land" do
- t=Target.new
- t.inline("mydouble (T_FIXNUM i) = T_FIXNUM (i + i)")
-
- t.mydouble(1).should eql(2)
- # and it doesn't wipe out other methods on the class
- t.foo.should eql(14)
-
- t.inline("dummy _ = T_FIXNUM 1")
- t.mydouble(1).should eql(2)
- t.dummy("dummyvar").should eql(1)
- # FIXME this one is waiting for support of Control.Exception in
- # JHC
- # Fooclever.mydouble(2.3).should raise_error(RuntimeError)
- end
-
- it "can handle doubles" do
- t = Target.new
- t.inline("triple (T_FLOAT a) = T_FLOAT (a*3.0)")
- t.triple(3.4).should eql(10.2)
- end
-
- it "can handle booleans" do
- t=Target.new
- t.inline(<<END
-my_negate T_TRUE = T_FALSE
-my_negate T_FALSE = T_TRUE
-my_negate _ = error "argh, something went wrong"
-END
- )
- t.my_negate(false).should eql(true)
- t.my_negate(true).should eql(false)
- end
-
- it "can handle nils too" do
- t=Target.new
- t.inline("give_me_a_nil _ = T_NIL")
- t.give_me_a_nil(1).should eql(nil)
- end
-
- it "can handle strings" do
- t=Target.new
- t.inline("reverse (T_STRING s) = T_STRING $ Prelude.reverse s")
- t.reverse("foot").should eql("toof")
- end
-
- def be_small
- simple_matcher("a small number") { |given| given == 2 or given == 4}
- end
-
- it "can be called in a block" do
- t=Target.new
- t.inline("foo (T_FIXNUM i) = T_FIXNUM (i*2)")
- (1..2).each do |x|
- t.foo(x).should be_small
- end
- end
-end
View
21 tasks/rspec.rake
@@ -1,21 +0,0 @@
-begin
- require 'spec'
-rescue LoadError
- require 'rubygems' unless ENV['NO_RUBYGEMS']
- require 'spec'
-end
-begin
- require 'spec/rake/spectask'
-rescue LoadError
- puts <<-EOS
-To use rspec for testing you must install rspec gem:
- gem install rspec
-EOS
- exit(0)
-end
-
-desc "Run the specs under spec/models"
-Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--options', "spec/spec.opts"]
- t.spec_files = FileList['spec/**/*_spec.rb']
-end
Please sign in to comment.
Something went wrong with that request. Please try again.