1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Infinity returns null when serialized

From RFC4627:

  Numeric values that cannot be represented as sequences of digits (such
  as Infinity and NaN) are not permitted.

NaN is invalid, so we already return null.
This commit is contained in:
Matthew Horan 2012-12-30 13:52:14 -05:00
parent e183803784
commit 857a1a0383
2 changed files with 10 additions and 1 deletions

View file

@ -408,6 +408,11 @@ describe Capybara::Webkit::Driver do
result.should == nil
end
it "evaluates Infinity and returns null" do
result = driver.evaluate_script(%<Infinity>)
result.should == nil
end
it "evaluates Javascript and returns an object" do
result = driver.evaluate_script(%<({ 'one' : 1 })>)
result.should == { 'one' => 1 }

View file

@ -1,4 +1,5 @@
#include "JsonSerializer.h"
#include <cmath>
JsonSerializer::JsonSerializer(QObject *parent) : QObject(parent) {
}
@ -24,7 +25,10 @@ void JsonSerializer::addVariant(const QVariant &object) {
}
break;
case QMetaType::Double:
m_buffer.append(object.toString());
if (std::isinf(object.toDouble()))
m_buffer.append("null");
else
m_buffer.append(object.toString());
break;
case QMetaType::QVariantMap:
{