@@ -1228,6 +1228,57 @@ TEST_F(LLVMCodeBuilderTest, Floor)
12281228 addOpTest (nan, 0 );
12291229}
12301230
1231+ TEST_F (LLVMCodeBuilderTest, Ceil)
1232+ {
1233+ std::string expected;
1234+
1235+ auto addOpTest = [this , &expected](Value v1, double expectedResult) {
1236+ createBuilder (true );
1237+
1238+ m_builder->addConstValue (v1);
1239+ m_builder->createCeil ();
1240+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1241+
1242+ m_builder->addConstValue (v1);
1243+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
1244+ m_builder->createCeil ();
1245+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1246+
1247+ std::stringstream stream;
1248+ stream << expectedResult;
1249+ std::string str = stream.str () + ' \n ' ;
1250+ std::string expected = str + str;
1251+
1252+ auto code = m_builder->finalize ();
1253+ auto ctx = code->createExecutionContext (&m_target);
1254+
1255+ testing::internal::CaptureStdout ();
1256+ code->run (ctx.get ());
1257+ const std::string quotes1 = v1.isString () ? " \" " : " " ;
1258+ ASSERT_THAT (testing::internal::GetCapturedStdout (), Eq (expected)) << quotes1 << v1.toString () << quotes1;
1259+ };
1260+
1261+ static const double inf = std::numeric_limits<double >::infinity ();
1262+ static const double nan = std::numeric_limits<double >::quiet_NaN ();
1263+
1264+ addOpTest (8.0 , 8.0 );
1265+ addOpTest (3.2 , 4.0 );
1266+ addOpTest (3.5 , 4.0 );
1267+ addOpTest (3.6 , 4.0 );
1268+ addOpTest (0.4 , 1.0 );
1269+ addOpTest (0.0 , 0.0 );
1270+ addOpTest (-0.0 , -0.0 );
1271+ addOpTest (-2.4 , -2.0 );
1272+ addOpTest (-2.5 , -2.0 );
1273+ addOpTest (-2.6 , -2.0 );
1274+ addOpTest (-0.4 , -0.0 );
1275+ addOpTest (-0.5 , -0.0 );
1276+ addOpTest (-0.51 , -0.0 );
1277+ addOpTest (inf, inf);
1278+ addOpTest (-inf, -inf);
1279+ addOpTest (nan, 0 );
1280+ }
1281+
12311282TEST_F (LLVMCodeBuilderTest, Yield)
12321283{
12331284 auto build = [this ]() {
0 commit comments