Просмотр исходного кода

LibJS: Use "%d" to stringify numeric values that are whole integers

This unbreaks a bunch of the JS tests since they were now printing all
the numbers as "1.000000" instead of "1".
Andreas Kling 5 лет назад
Родитель
Сommit
a8dc6501de
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      Libraries/LibJS/Runtime/Value.cpp

+ 2 - 0
Libraries/LibJS/Runtime/Value.cpp

@@ -58,6 +58,8 @@ String Value::to_string() const
             return "NaN";
             return "NaN";
 
 
         // FIXME: This needs improvement.
         // FIXME: This needs improvement.
+        if ((double)to_i32() == as_double())
+            return String::number(to_i32());
         return String::format("%f", as_double());
         return String::format("%f", as_double());
     }
     }