From 29df28dabdce2b418db28bae6e1cdffe946a625f Mon Sep 17 00:00:00 2001 From: Jeff Lewis Date: Wed, 4 Dec 2024 16:27:36 -0700 Subject: [PATCH] fix JS tests --- modules/bootstrapped/test/src/smithy4s/DocumentSpec.scala | 6 +++++- .../http/internals/SchemaVisitorMetadataReader.scala | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/bootstrapped/test/src/smithy4s/DocumentSpec.scala b/modules/bootstrapped/test/src/smithy4s/DocumentSpec.scala index 710d6fc26..d875f0b7b 100644 --- a/modules/bootstrapped/test/src/smithy4s/DocumentSpec.scala +++ b/modules/bootstrapped/test/src/smithy4s/DocumentSpec.scala @@ -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 ) } diff --git a/modules/core/src/smithy4s/http/internals/SchemaVisitorMetadataReader.scala b/modules/core/src/smithy4s/http/internals/SchemaVisitorMetadataReader.scala index ce168a25e..fe06f52d0 100644 --- a/modules/core/src/smithy4s/http/internals/SchemaVisitorMetadataReader.scala +++ b/modules/core/src/smithy4s/http/internals/SchemaVisitorMetadataReader.scala @@ -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( @@ -67,7 +67,7 @@ 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( @@ -75,11 +75,11 @@ private[http] class SchemaVisitorMetadataReader( ) 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],