// BEGIN mycpp output #include "mycpp/runtime.h" GLOBAL_STR(str0, "x = %d"); GLOBAL_STR(str1, "b = %d"); GLOBAL_STR(str2, ""); GLOBAL_STR(str3, "x = %d"); GLOBAL_STR(str4, "s = %r"); GLOBAL_STR(str5, "x = %d"); GLOBAL_STR(str6, "y = %d"); GLOBAL_STR(str7, "foo"); GLOBAL_STR(str8, "const"); GLOBAL_STR(str9, "print formatted = %d"); GLOBAL_STR(str10, "const"); GLOBAL_STR(str11, "log formatted = %d"); namespace test_default_args { // forward declare class Foo; } // forward declare namespace test_default_args namespace test_default_args { // declare void f(int x, bool b = false); void g(int x, BigStr* s = str2); class Foo { public: Foo(int x, int y = 42); void Print(); int x{}; int y{}; static constexpr ObjHeader obj_header() { return ObjHeader::ClassScanned(0, sizeof(Foo)); } DISALLOW_COPY_AND_ASSIGN(Foo) }; void run_tests(); void run_benchmarks(); } // declare namespace test_default_args namespace test_default_args { // define void f(int x, bool b) { mylib::print_stderr(StrFormat("x = %d", x)); mylib::print_stderr(StrFormat("b = %d", b)); } void g(int x, BigStr* s) { mylib::print_stderr(StrFormat("x = %d", x)); mylib::print_stderr(StrFormat("s = %r", s)); } Foo::Foo(int x, int y) { this->x = x; this->y = y; } void Foo::Print() { mylib::print_stderr(StrFormat("x = %d", this->x)); mylib::print_stderr(StrFormat("y = %d", this->y)); } void run_tests() { test_default_args::Foo* f1 = nullptr; test_default_args::Foo* f2 = nullptr; test_default_args::Foo* f3 = nullptr; f(5); f(6, true); f(7, true); g(99, str7); f1 = Alloc(8); f2 = Alloc(9, 43); f3 = Alloc(0, 44); f1->Print(); f2->Print(); f3->Print(); print(str8); print(StrFormat("print formatted = %d", true)); mylib::print_stderr(str10); mylib::print_stderr(StrFormat("log formatted = %d", true)); } void run_benchmarks() { FAIL(kNotImplemented); // Python NotImplementedError } } // define namespace test_default_args