@@ -290,6 +290,54 @@ TEST_F(LLVMCodeBuilderTest, Subtract)
290290 ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
291291}
292292
293+ TEST_F (LLVMCodeBuilderTest, Multiply)
294+ {
295+ std::string expected;
296+
297+ auto addOpTest = [this , &expected](Value v1, Value v2, double expectedResult) {
298+ m_builder->addConstValue (v1);
299+ m_builder->addConstValue (v2);
300+ m_builder->createMul ();
301+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
302+
303+ m_builder->addConstValue (v1);
304+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
305+ m_builder->addConstValue (v2);
306+ m_builder->addFunctionCall (" test_const_number" , Compiler::StaticType::Number, { Compiler::StaticType::Number });
307+ m_builder->createMul ();
308+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
309+
310+ std::string str = Value (expectedResult).toString () + ' \n ' ;
311+ expected += str;
312+ expected += str;
313+ };
314+
315+ createBuilder (true );
316+
317+ addOpTest (50 , 2 , 100 );
318+ addOpTest (-500 , 25 , -12500 );
319+ addOpTest (" -500" , -25 , 12500 );
320+ addOpTest (" 2.54" , " 6.28" , 15.9512 );
321+ addOpTest (true , true , 1 );
322+ addOpTest (" Infinity" , " Infinity" , std::numeric_limits<double >::infinity ());
323+ addOpTest (" Infinity" , 0 , std::numeric_limits<double >::quiet_NaN ());
324+ addOpTest (" Infinity" , 2 , std::numeric_limits<double >::infinity ());
325+ addOpTest (" Infinity" , " -Infinity" , -std::numeric_limits<double >::infinity ());
326+ addOpTest (" -Infinity" , " Infinity" , -std::numeric_limits<double >::infinity ());
327+ addOpTest (" -Infinity" , 0 , std::numeric_limits<double >::quiet_NaN ());
328+ addOpTest (" -Infinity" , 2 , -std::numeric_limits<double >::infinity ());
329+ addOpTest (" -Infinity" , " -Infinity" , std::numeric_limits<double >::infinity ());
330+ addOpTest (1 , " NaN" , 0 );
331+ addOpTest (" NaN" , 1 , 0 );
332+
333+ auto code = m_builder->finalize ();
334+ auto ctx = code->createExecutionContext (&m_target);
335+
336+ testing::internal::CaptureStdout ();
337+ code->run (ctx.get ());
338+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
339+ }
340+
293341TEST_F (LLVMCodeBuilderTest, Yield)
294342{
295343 auto build = [this ]() {
0 commit comments