@@ -1646,6 +1646,50 @@ TEST_F(LLVMCodeBuilderTest, Ln)
16461646 addOpTest (nan, -inf);
16471647}
16481648
1649+ TEST_F (LLVMCodeBuilderTest, Log10)
1650+ {
1651+ std::string expected;
1652+
1653+ auto addOpTest = [this , &expected](Value v1, double expectedResult) {
1654+ createBuilder (true );
1655+
1656+ m_builder->addConstValue (v1);
1657+ m_builder->createLog10 ();
1658+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1659+
1660+ m_builder->addConstValue (v1);
1661+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
1662+ m_builder->createLog10 ();
1663+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1664+
1665+ std::stringstream stream;
1666+ stream << expectedResult;
1667+ std::string str = stream.str () + ' \n ' ;
1668+ std::string expected = str + str;
1669+
1670+ auto code = m_builder->finalize ();
1671+ auto ctx = code->createExecutionContext (&m_target);
1672+
1673+ testing::internal::CaptureStdout ();
1674+ code->run (ctx.get ());
1675+ const std::string quotes1 = v1.isString () ? " \" " : " " ;
1676+ ASSERT_THAT (testing::internal::GetCapturedStdout (), Eq (expected)) << quotes1 << v1.toString () << quotes1;
1677+ };
1678+
1679+ static const double inf = std::numeric_limits<double >::infinity ();
1680+ static const double nan = std::numeric_limits<double >::quiet_NaN ();
1681+
1682+ addOpTest (10.0 , 1.0 );
1683+ addOpTest (1000.0 , 3.0 );
1684+ addOpTest (0.01 , -2.0 );
1685+ addOpTest (0.0 , -inf);
1686+ addOpTest (-0.0 , -inf);
1687+ addOpTest (-0.7 , nan);
1688+ addOpTest (inf, inf);
1689+ addOpTest (-inf, nan);
1690+ addOpTest (nan, -inf);
1691+ }
1692+
16491693TEST_F (LLVMCodeBuilderTest, Yield)
16501694{
16511695 auto build = [this ]() {
0 commit comments