mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
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:
11
test/test_suite/comments/complex_nesting.c3
Normal file
11
test/test_suite/comments/complex_nesting.c3
Normal 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!
|
||||
15
test/test_suite/comments/instring_comments.c3
Normal file
15
test/test_suite/comments/instring_comments.c3
Normal 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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user