Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Created June 10, 2009 03:19
Show Gist options
  • Select an option

  • Save knowtheory/126993 to your computer and use it in GitHub Desktop.

Select an option

Save knowtheory/126993 to your computer and use it in GitHub Desktop.
=begin
This is my control script.
DataMapper by itself doesn't seem to explode when using BigDecimal.
umbra:dm-specs ted$ ruby scratch_pad/big_dec.rb
Create
Find
Access Value
umbra:dm-specs ted$
=end
require 'rubygems'
require 'dm-core'
class BigDec
include DataMapper::Resource
property :id, Serial
property :value, BigDecimal
end
DataMapper.setup(:default, :adapter=>:in_memory)
puts "Create"
b = BigDec.create(:value => "9E69999999")
puts "Find"
b = BigDec.first
puts "Access Value"
b.value
=begin
umbra:dm-specs ted$ spec specs/spec_big_decimal_bug.rb -f s -c
BigDecimal bug
Create
Illegal instruction
umbra:dm-specs ted$
=end
here = File.dirname(__FILE__)
require File.join(here, 'spec_helper')
class BigDec
include DataMapper::Resource
property :id, Serial
property :value, BigDecimal
end
describe "BigDecimal bug" do
it "should throw an error, rather than exploding in memory" do
DataMapper.setup(:default, :adapter=>:in_memory)
puts "Create"
b = BigDec.create(:value => "9E69999999")
puts "Find"
b = BigDec.first
puts "Access Value"
b.value.should raise_error
end
end
require 'rubygems'
require 'spec'
require 'extlib'
require 'dm-core'
require 'dm-validations'
here = File.dirname(__FILE__)
#DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://localhost/dm_specs")
#DataMapper.setup(:default, "sqlite3:./dm_specs.db")
#DataMapper.setup(:default, "postgres://localhost/dm_specs")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment