@@ -1559,6 +1559,48 @@ TEST_F(LLVMCodeBuilderTest, Acos)
15591559 addOpTest (nan, 90.0 );
15601560}
15611561
1562+ TEST_F (LLVMCodeBuilderTest, Atan)
1563+ {
1564+ std::string expected;
1565+
1566+ auto addOpTest = [this , &expected](Value v1, double expectedResult) {
1567+ createBuilder (true );
1568+
1569+ m_builder->addConstValue (v1);
1570+ m_builder->createAtan ();
1571+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1572+
1573+ m_builder->addConstValue (v1);
1574+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
1575+ m_builder->createAtan ();
1576+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number });
1577+
1578+ std::stringstream stream;
1579+ stream << expectedResult;
1580+ std::string str = stream.str () + ' \n ' ;
1581+ std::string expected = str + str;
1582+
1583+ auto code = m_builder->finalize ();
1584+ auto ctx = code->createExecutionContext (&m_target);
1585+
1586+ testing::internal::CaptureStdout ();
1587+ code->run (ctx.get ());
1588+ const std::string quotes1 = v1.isString () ? " \" " : " " ;
1589+ ASSERT_THAT (testing::internal::GetCapturedStdout (), Eq (expected)) << quotes1 << v1.toString () << quotes1;
1590+ };
1591+
1592+ static const double inf = std::numeric_limits<double >::infinity ();
1593+ static const double nan = std::numeric_limits<double >::quiet_NaN ();
1594+
1595+ addOpTest (1.0 , 45.0 );
1596+ addOpTest (0.0 , 0.0 );
1597+ addOpTest (-0.0 , -0.0 );
1598+ addOpTest (-1.0 , -45.0 );
1599+ addOpTest (inf, 90.0 );
1600+ addOpTest (-inf, -90.0 );
1601+ addOpTest (nan, 0.0 );
1602+ }
1603+
15621604TEST_F (LLVMCodeBuilderTest, Yield)
15631605{
15641606 auto build = [this ]() {
0 commit comments