Skip to content

Commit

Permalink
fix JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjkl committed Dec 4, 2024
1 parent c78ff53 commit 29df28d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion modules/bootstrapped/test/src/smithy4s/DocumentSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,14 @@ class DocumentSpec() extends FunSuite {

val in = Double.NaN
val error = Try(Document.encode(in)).failed.get
val expectedMessage =
if (weaver.Platform.isJS) "For input string: \"NaN\""
else
"Character N is neither a decimal digit number, decimal point, nor \"e\" notation exponential mark."

expect.same(
error.getMessage,
"Character N is neither a decimal digit number, decimal point, nor \"e\" notation exponential mark."
expectedMessage
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private[http] class SchemaVisitorMetadataReader(
tag match {
case Primitive.PDouble =>
val decode: MetaDecode[Double] =
primitivePrivate(shapeId, hints, tag, desc)
primitiveHandler(shapeId, hints, tag, desc)
decode.map(d =>
if (!allowNaNAndInfiniteValues && (d.isNaN || d.isInfinite))
throw MetadataError.ImpossibleDecoding(
Expand All @@ -67,19 +67,19 @@ private[http] class SchemaVisitorMetadataReader(
)
case Primitive.PFloat =>
val decode: MetaDecode[Float] =
primitivePrivate(shapeId, hints, tag, desc)
primitiveHandler(shapeId, hints, tag, desc)
decode.map(f =>
if (!allowNaNAndInfiniteValues && (f.isNaN || f.isInfinite))
throw MetadataError.ImpossibleDecoding(
s"NaN or pos/neg infinity are not allowed for inputs of type $desc"
)
else f
)
case _ => primitivePrivate(shapeId, hints, tag, desc)
case _ => primitiveHandler(shapeId, hints, tag, desc)
}
}

private def primitivePrivate[P](
private def primitiveHandler[P](
shapeId: ShapeId,
hints: Hints,
tag: Primitive[P],
Expand Down

0 comments on commit 29df28d

Please sign in to comment.