@@ -1601,6 +1601,51 @@ TEST_F(LLVMCodeBuilderTest, Atan)
16011601 addOpTest (nan, 0.0 );
16021602}
16031603
1604+ TEST_F (LLVMCodeBuilderTest, Ln)
1605+ {
1606+ std::string expected;
1607+
1608+ auto addOpTest = [this , &expected](Value v1, double expectedResult) {
1609+ createBuilder (true );
1610+
1611+ m_builder->addConstValue (v1);
1612+ m_builder->createLn ();
1613+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1614+
1615+ m_builder->addConstValue (v1);
1616+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
1617+ m_builder->createLn ();
1618+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1619+
1620+ std::stringstream stream;
1621+ stream << expectedResult;
1622+ std::string str = stream.str () + ' \n ' ;
1623+ std::string expected = str + str;
1624+
1625+ auto code = m_builder->finalize ();
1626+ auto ctx = code->createExecutionContext (&m_target);
1627+
1628+ testing::internal::CaptureStdout ();
1629+ code->run (ctx.get ());
1630+ const std::string quotes1 = v1.isString () ? " \" " : " " ;
1631+ ASSERT_THAT (testing::internal::GetCapturedStdout (), Eq (expected)) << quotes1 << v1.toString () << quotes1;
1632+ };
1633+
1634+ static const double inf = std::numeric_limits<double >::infinity ();
1635+ static const double nan = std::numeric_limits<double >::quiet_NaN ();
1636+
1637+ addOpTest (std::exp (1.0 ), 1.0 );
1638+ addOpTest (std::exp (2.0 ), 2.0 );
1639+ addOpTest (std::exp (0.3 ), 0.3 );
1640+ addOpTest (1.0 , 0.0 );
1641+ addOpTest (0.0 , -inf);
1642+ addOpTest (-0.0 , -inf);
1643+ addOpTest (-0.7 , -nan); // negative NaN shouldn't be a problem
1644+ addOpTest (inf, inf);
1645+ addOpTest (-inf, -nan);
1646+ addOpTest (nan, -inf);
1647+ }
1648+
16041649TEST_F (LLVMCodeBuilderTest, Yield)
16051650{
16061651 auto build = [this ]() {
0 commit comments