test: added comprehensive tests for in-string & complex nested comments (#2956)

* test: added comprehensive tests for in-string & complex nested comments

* Properly handle error

---------

Co-authored-by: Christoffer Lerno <christoffer.lerno@gmail.com>
This commit is contained in:
mmoustafa8108
2026-02-20 14:24:08 +02:00
committed by GitHub
parent 4b13ad692a
commit 5055e86518
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
// this test stress-tests the compiler ability to handle complex comments
/* first of all, I wanna say that <* linux *> is the best OS ever!
secondly, #!pizza, it's a masterpiece... nothing is better than pizza, // thanks to who cooked it for the first time..
I want to rant windows but I'm afraid of it getting mad and not supporting C3.. /* I'll not cause problems, just for this time */
I'm forced to use windows for ~4 more months just for my school.. /* this is TERRIBLE guys */
#! this line would fail because it's "#!" isn't in the right place (the first two characters of a file).. but since we're already in a comment, it' fine!
*/
#! this line should raise an error! // #error: a global
// while this shouldn't!

View File

@@ -0,0 +1,15 @@
module instring_comments;
import std;
// this test proves the compiler can handle in string comments reliabely.
fn void test_len() @test {
String foo = "Hello, // world!";
String bar = "Hello, /* world */!";
assert(foo.len == 16);
assert(bar.len == 19);
}