Created
June 10, 2009 03:19
-
-
Save knowtheory/126993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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