@@ -29,6 +29,13 @@ auto to_string(const sourcemeta::core::JSON::Type type) -> std::string {
2929 }
3030}
3131
32+ auto value_type_name (const sourcemeta::core::JSON &value) -> std::string {
33+ if (value.type () == sourcemeta::core::JSON::Type::Decimal) {
34+ return value.to_decimal ().is_integer () ? " integer" : " number" ;
35+ }
36+ return to_string (value.type ());
37+ }
38+
3239auto escape_string (const std::string &input) -> std::string {
3340 std::ostringstream result;
3441 result << ' "' ;
@@ -1693,32 +1700,32 @@ auto describe(const bool valid, const Instruction &step,
16931700 if (step.type == sourcemeta::blaze::InstructionIndex::AssertionGreaterEqual) {
16941701 std::ostringstream message;
16951702 const auto &value{instruction_value<ValueJSON>(step)};
1696- message << " The " << to_string (target. type () ) << " value " ;
1703+ message << " The " << value_type_name (target) << " value " ;
16971704 stringify (target, message);
16981705 message << " was expected to be greater than or equal to the "
1699- << to_string (value. type () ) << " " ;
1706+ << value_type_name (value) << " " ;
17001707 stringify (value, message);
17011708 return message.str ();
17021709 }
17031710
17041711 if (step.type == sourcemeta::blaze::InstructionIndex::AssertionLessEqual) {
17051712 std::ostringstream message;
17061713 const auto &value{instruction_value<ValueJSON>(step)};
1707- message << " The " << to_string (target. type () ) << " value " ;
1714+ message << " The " << value_type_name (target) << " value " ;
17081715 stringify (target, message);
17091716 message << " was expected to be less than or equal to the "
1710- << to_string (value. type () ) << " " ;
1717+ << value_type_name (value) << " " ;
17111718 stringify (value, message);
17121719 return message.str ();
17131720 }
17141721
17151722 if (step.type == sourcemeta::blaze::InstructionIndex::AssertionGreater) {
17161723 std::ostringstream message;
17171724 const auto &value{instruction_value<ValueJSON>(step)};
1718- message << " The " << to_string (target. type () ) << " value " ;
1725+ message << " The " << value_type_name (target) << " value " ;
17191726 stringify (target, message);
1720- message << " was expected to be greater than the "
1721- << to_string (value. type ()) << " " ;
1727+ message << " was expected to be greater than the " << value_type_name (value)
1728+ << " " ;
17221729 stringify (value, message);
17231730 if (!valid && value == target) {
17241731 message << " , but they were equal" ;
@@ -1730,9 +1737,9 @@ auto describe(const bool valid, const Instruction &step,
17301737 if (step.type == sourcemeta::blaze::InstructionIndex::AssertionLess) {
17311738 std::ostringstream message;
17321739 const auto &value{instruction_value<ValueJSON>(step)};
1733- message << " The " << to_string (target. type () ) << " value " ;
1740+ message << " The " << value_type_name (target) << " value " ;
17341741 stringify (target, message);
1735- message << " was expected to be less than the " << to_string (value. type () )
1742+ message << " was expected to be less than the " << value_type_name (value)
17361743 << " " ;
17371744 stringify (value, message);
17381745 if (!valid && value == target) {
@@ -1786,10 +1793,10 @@ auto describe(const bool valid, const Instruction &step,
17861793 if (step.type == sourcemeta::blaze::InstructionIndex::AssertionDivisible) {
17871794 std::ostringstream message;
17881795 const auto &value{instruction_value<ValueJSON>(step)};
1789- message << " The " << to_string (target. type () ) << " value " ;
1796+ message << " The " << value_type_name (target) << " value " ;
17901797 stringify (target, message);
1791- message << " was expected to be divisible by the "
1792- << to_string (value. type ()) << " " ;
1798+ message << " was expected to be divisible by the " << value_type_name (value)
1799+ << " " ;
17931800 stringify (value, message);
17941801 return message.str ();
17951802 }
0 commit comments