@@ -1690,6 +1690,49 @@ TEST_F(LLVMCodeBuilderTest, Log10)
16901690 addOpTest (nan, -inf);
16911691}
16921692
1693+ TEST_F (LLVMCodeBuilderTest, Exp)
1694+ {
1695+ std::string expected;
1696+
1697+ auto addOpTest = [this , &expected](Value v1, double expectedResult) {
1698+ createBuilder (true );
1699+
1700+ m_builder->addConstValue (v1);
1701+ m_builder->createExp ();
1702+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1703+
1704+ m_builder->addConstValue (v1);
1705+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
1706+ m_builder->createExp ();
1707+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1708+
1709+ std::stringstream stream;
1710+ stream << expectedResult;
1711+ std::string str = stream.str () + ' \n ' ;
1712+ std::string expected = str + str;
1713+
1714+ auto code = m_builder->finalize ();
1715+ auto ctx = code->createExecutionContext (&m_target);
1716+
1717+ testing::internal::CaptureStdout ();
1718+ code->run (ctx.get ());
1719+ const std::string quotes1 = v1.isString () ? " \" " : " " ;
1720+ ASSERT_THAT (testing::internal::GetCapturedStdout (), Eq (expected)) << quotes1 << v1.toString () << quotes1;
1721+ };
1722+
1723+ static const double inf = std::numeric_limits<double >::infinity ();
1724+ static const double nan = std::numeric_limits<double >::quiet_NaN ();
1725+
1726+ addOpTest (1.0 , std::exp (1.0 ));
1727+ addOpTest (0.5 , std::exp (0.5 ));
1728+ addOpTest (0.0 , 1.0 );
1729+ addOpTest (-0.0 , 1.0 );
1730+ addOpTest (-0.7 , std::exp (-0.7 ));
1731+ addOpTest (inf, inf);
1732+ addOpTest (-inf, 0.0 );
1733+ addOpTest (nan, 1.0 );
1734+ }
1735+
16931736TEST_F (LLVMCodeBuilderTest, Yield)
16941737{
16951738 auto build = [this ]() {
0 commit comments