| 3 | EM_JS(void, test_remove_cpp_comments_in_shaders, (void), { |
| 4 | var numFailed = 0; |
| 5 | function test(input, expected) { |
| 6 | var obtained = remove_cpp_comments_in_shaders(input); |
| 7 | function remove_nl(t) { return t.replace(/\\n/g, "\\\\\\n")} |
| 8 | |
| 9 | if (obtained == expected) { |
| 10 | out(`OK: '${remove_nl(input)}' -> '${remove_nl(expected)}'`); |
| 11 | } else { |
| 12 | err(`\\nFailed! \\nInput: '${remove_nl(input)}'\\nObtained: '${remove_nl(obtained)}'\\nExpected: '${remove_nl(expected)}'\\n`); |
| 13 | ++numFailed; |
| 14 | } |
| 15 | } |
| 16 | test('foo(); // test // test2 // test3', 'foo(); '); // Test that C++ comments '//' are removed |
| 17 | test('foo(); / /// test', 'foo(); / '); // Test that no confusion with slightly similar looking inputs |
| 18 | test('foo(); // /*', 'foo(); '); // Test that // takes away /* |