Fix RDF.Double to not accept +INF as a valid value
This commit is contained in:
parent
874b0d5eea
commit
dc2b070e05
|
@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
|
||||||
correctly
|
correctly
|
||||||
- `true` and `false` with capital letters are no longer valid `RDF.Boolean`s
|
- `true` and `false` with capital letters are no longer valid `RDF.Boolean`s
|
||||||
following the XSD specification; the same applies for booleans in Turtle
|
following the XSD specification; the same applies for booleans in Turtle
|
||||||
|
- `+INF` is no longer a valid `RDF.Double` (positive infinity doesn't expect a sign)
|
||||||
|
|
||||||
|
|
||||||
[Compare v0.6.0...HEAD](https://github.com/marcelotto/rdf-ex/compare/v0.6.0...HEAD)
|
[Compare v0.6.0...HEAD](https://github.com/marcelotto/rdf-ex/compare/v0.6.0...HEAD)
|
||||||
|
|
|
@ -40,7 +40,6 @@ defmodule RDF.Double do
|
||||||
:error ->
|
:error ->
|
||||||
case String.upcase(value) do
|
case String.upcase(value) do
|
||||||
"INF" -> :positive_infinity
|
"INF" -> :positive_infinity
|
||||||
"+INF" -> :positive_infinity
|
|
||||||
"-INF" -> :negative_infinity
|
"-INF" -> :negative_infinity
|
||||||
"NAN" -> :nan
|
"NAN" -> :nan
|
||||||
_ -> super(value, opts)
|
_ -> super(value, opts)
|
||||||
|
|
|
@ -92,7 +92,7 @@ defmodule RDF.BooleanTest do
|
||||||
|
|
||||||
assert RDF.double(1) |> RDF.Boolean.cast() == RDF.true
|
assert RDF.double(1) |> RDF.Boolean.cast() == RDF.true
|
||||||
assert RDF.double(0.1) |> RDF.Boolean.cast() == RDF.true
|
assert RDF.double(0.1) |> RDF.Boolean.cast() == RDF.true
|
||||||
assert RDF.double("+INF") |> RDF.Boolean.cast() == RDF.true
|
assert RDF.double("-INF") |> RDF.Boolean.cast() == RDF.true
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag skip: "TODO: RDF.Float datatype"
|
@tag skip: "TODO: RDF.Float datatype"
|
||||||
|
|
|
@ -25,11 +25,10 @@ defmodule RDF.DoubleTest do
|
||||||
"3E1" => { 3.0E1 , "3E1" , "3.0E1" },
|
"3E1" => { 3.0E1 , "3E1" , "3.0E1" },
|
||||||
"INF" => { :positive_infinity , nil , "INF" },
|
"INF" => { :positive_infinity , nil , "INF" },
|
||||||
"Inf" => { :positive_infinity , "Inf" , "INF" },
|
"Inf" => { :positive_infinity , "Inf" , "INF" },
|
||||||
"+INF" => { :positive_infinity , "+INF" , "INF" },
|
|
||||||
"-INF" => { :negative_infinity , nil , "-INF" },
|
"-INF" => { :negative_infinity , nil , "-INF" },
|
||||||
"NaN" => { :nan , nil , "NaN" },
|
"NaN" => { :nan , nil , "NaN" },
|
||||||
},
|
},
|
||||||
invalid: ~w(foo 12.xyz 1.0ez) ++ [true, false, "1.1e1 foo", "foo 1.1e1"]
|
invalid: ~w(foo 12.xyz 1.0ez +INF) ++ [true, false, "1.1e1 foo", "foo 1.1e1"]
|
||||||
|
|
||||||
|
|
||||||
describe "equality" do
|
describe "equality" do
|
||||||
|
@ -63,7 +62,7 @@ defmodule RDF.DoubleTest do
|
||||||
test "casting a double returns the input as it is" do
|
test "casting a double returns the input as it is" do
|
||||||
assert RDF.double(3.14) |> RDF.Double.cast() == RDF.double(3.14)
|
assert RDF.double(3.14) |> RDF.Double.cast() == RDF.double(3.14)
|
||||||
assert RDF.double("NAN") |> RDF.Double.cast() == RDF.double("NAN")
|
assert RDF.double("NAN") |> RDF.Double.cast() == RDF.double("NAN")
|
||||||
assert RDF.double("+INF") |> RDF.Double.cast() == RDF.double("+INF")
|
assert RDF.double("-INF") |> RDF.Double.cast() == RDF.double("-INF")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "casting a boolean" do
|
test "casting a boolean" do
|
||||||
|
|
Loading…
Reference in a new issue