Skip to content

Commit e4be611

Browse files
committed
Handle corner-case on canonicalizing a Double whose value is nil. (to_sxp issues).
1 parent ef2c1f9 commit e4be611

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/rdf/model/literal/double.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def canonicalize!
4343
# Can't use simple %f transformation due to special requirements from
4444
# N3 tests in representation
4545
@string = case
46+
when @object.nil? then 'NaN'
4647
when @object.nan? then 'NaN'
4748
when @object.infinite? then @object.to_s[0...-'inity'.length].upcase
4849
when @object.zero? then '0.0E0'

spec/model_literal_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ def self.literals(*selector)
615615
%w(-INF -INF),
616616
%w(+INF INF),
617617
#%w(NaN NaN),
618-
#%w(NAN NaN),
619-
%w(InF INF),
618+
#%w(NAN NaN),
619+
%w(InF INF),
620620
%w(3E1 3.0E1)
621621
]
622622
it_behaves_like 'RDF::Literal validation', RDF::XSD.double,
@@ -641,7 +641,7 @@ def self.literals(*selector)
641641
1.0 => ["1.0", "1.0E0"],
642642
0.0 => ["0.0", "0.0E0"],
643643
10.10 => ["10.1", "1.01E1"],
644-
123.456e4 => ["1234560.0", "1.23456E6"],
644+
123.456e4 => ["1234560.0", "1.23456E6"]
645645
}.each do |obj, (str, canon)|
646646
it "to_str #{obj} to #{str.inspect}" do
647647
expect(RDF::Literal::Double.new(obj).to_s).to eql str

0 commit comments

Comments
 (0)