Fix RDF.Literal.new/1 to handle decimals correctly
This commit is contained in:
parent
f89b34ed4b
commit
5b10ccd58b
3 changed files with 7 additions and 1 deletions
|
@ -18,7 +18,9 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
|
|||
|
||||
### Fixed
|
||||
|
||||
- language literals were not properly unescaped during Turtle parsing
|
||||
- language literals were not properly unescaped during Turtle parsing
|
||||
- `RDF.Literal.new/1` can take decimals and infers the datatype `xsd:decimal`
|
||||
correctly
|
||||
|
||||
|
||||
[Compare v0.6.0...HEAD](https://github.com/marcelotto/rdf-ex/compare/v0.6.0...HEAD)
|
||||
|
|
|
@ -48,6 +48,7 @@ defmodule RDF.Literal do
|
|||
def new(value) when is_boolean(value), do: RDF.Boolean.new(value)
|
||||
def new(value) when is_integer(value), do: RDF.Integer.new(value)
|
||||
def new(value) when is_float(value), do: RDF.Double.new(value)
|
||||
def new(%Decimal{} = value), do: RDF.Decimal.new(value)
|
||||
|
||||
def new(%Date{} = value), do: RDF.Date.new(value)
|
||||
def new(%Time{} = value), do: RDF.Time.new(value)
|
||||
|
|
|
@ -13,6 +13,7 @@ defmodule RDF.LiteralTest do
|
|||
RDF.String => ["foo"],
|
||||
RDF.Integer => [42],
|
||||
RDF.Double => [3.14],
|
||||
RDF.Decimal => [Decimal.from_float(3.14)],
|
||||
RDF.Boolean => [true, false],
|
||||
}
|
||||
|
||||
|
@ -55,6 +56,8 @@ defmodule RDF.LiteralTest do
|
|||
test "decimal" do
|
||||
assert Literal.new(3.14, datatype: XSD.decimal) == RDF.Decimal.new(3.14)
|
||||
assert Literal.new("3.14", datatype: XSD.decimal) == RDF.Decimal.new("3.14")
|
||||
assert Literal.new(Decimal.from_float(3.14), datatype: XSD.decimal) ==
|
||||
RDF.Decimal.new(Decimal.from_float(3.14))
|
||||
end
|
||||
|
||||
test "string" do
|
||||
|
|
Loading…
Reference in a new issue