@@ -962,6 +962,68 @@ TEST_F(LLVMCodeBuilderTest, AndOr)
962962 addOpTest (" nan" , nan);
963963}
964964
965+ TEST_F (LLVMCodeBuilderTest, Not)
966+ {
967+ auto addOpTest = [this ](Value v) {
968+ createBuilder (true );
969+
970+ m_builder->addConstValue (v);
971+ m_builder->createNot ();
972+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
973+
974+ m_builder->addConstValue (v);
975+ callConstFuncForType (v.type ());
976+ m_builder->createNot ();
977+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
978+
979+ std::string str = Value (!v.toBool ()).toString () + ' \n ' ;
980+ std::string expected = str + str;
981+
982+ auto code = m_builder->finalize ();
983+ auto ctx = code->createExecutionContext (&m_target);
984+
985+ testing::internal::CaptureStdout ();
986+ code->run (ctx.get ());
987+ const std::string quotes = v.isString () ? " \" " : " " ;
988+ ASSERT_THAT (testing::internal::GetCapturedStdout (), Eq (expected)) << " NOT: " << quotes << v.toString () << quotes;
989+ };
990+
991+ addOpTest (10 );
992+ addOpTest (-4.25 );
993+ addOpTest (5.312 );
994+ addOpTest (1 );
995+ addOpTest (0 );
996+
997+ addOpTest (true );
998+ addOpTest (false );
999+
1000+ addOpTest (" abc" );
1001+ addOpTest (" 5.25" );
1002+ addOpTest (" 0" );
1003+
1004+ static const double inf = std::numeric_limits<double >::infinity ();
1005+ static const double nan = std::numeric_limits<double >::quiet_NaN ();
1006+
1007+ addOpTest (inf);
1008+ addOpTest (-inf);
1009+ addOpTest (nan);
1010+
1011+ addOpTest (" true" );
1012+ addOpTest (" false" );
1013+ addOpTest (" TRUE" );
1014+ addOpTest (" FALSE" );
1015+
1016+ addOpTest (" 00001" );
1017+ addOpTest (" 00000" );
1018+
1019+ addOpTest (" Infinity" );
1020+ addOpTest (" infinity" );
1021+ addOpTest (" -Infinity" );
1022+ addOpTest (" -infinity" );
1023+ addOpTest (" NaN" );
1024+ addOpTest (" nan" );
1025+ }
1026+
9651027TEST_F (LLVMCodeBuilderTest, Yield)
9661028{
9671029 auto build = [this ]() {
0 commit comments