mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Macro methods added.
This commit is contained in:
committed by
Christoffer Lerno
parent
9572c4afc9
commit
038ed7f9d5
34
test/test_suite/macro_methods/access.c3
Normal file
34
test/test_suite/macro_methods/access.c3
Normal file
@@ -0,0 +1,34 @@
|
||||
struct An1
|
||||
{
|
||||
An3 x;
|
||||
}
|
||||
|
||||
struct An3
|
||||
{
|
||||
An2 y;
|
||||
}
|
||||
|
||||
struct An2
|
||||
{
|
||||
}
|
||||
|
||||
extern func void printf(char *string);
|
||||
|
||||
macro void An2.helloWorld(An2 *an2)
|
||||
{
|
||||
printf("An2 hello\n");
|
||||
}
|
||||
|
||||
func void check()
|
||||
{
|
||||
printf("Checking\n");
|
||||
}
|
||||
|
||||
|
||||
func void main()
|
||||
{
|
||||
An1 an;
|
||||
an.x.y.@helloWorld();
|
||||
An2 a;
|
||||
a.@helloWorld();
|
||||
}
|
||||
56
test/test_suite/macro_methods/macro_method_fails.c3
Normal file
56
test/test_suite/macro_methods/macro_method_fails.c3
Normal file
@@ -0,0 +1,56 @@
|
||||
struct An1
|
||||
{
|
||||
An3 x;
|
||||
}
|
||||
|
||||
struct An3
|
||||
{
|
||||
An2 y;
|
||||
}
|
||||
|
||||
struct An2
|
||||
{
|
||||
}
|
||||
|
||||
extern func void printf(char *string);
|
||||
|
||||
macro void An2.helloWorld(An2 *an2)
|
||||
{
|
||||
printf("An2 hello\n");
|
||||
}
|
||||
|
||||
func void check()
|
||||
{
|
||||
printf("Checking\n");
|
||||
}
|
||||
|
||||
|
||||
func void test1()
|
||||
{
|
||||
An1 an;
|
||||
an.x.y.@helloWorld; // #error: macro name must be followed by '('
|
||||
}
|
||||
|
||||
func void test2()
|
||||
{
|
||||
An2 a;
|
||||
a.@helloWorld; // #error: A macro name must be followed by '('
|
||||
}
|
||||
|
||||
func void test3()
|
||||
{
|
||||
An2 a;
|
||||
a.@helloWorld.b; // #error: No such member or function could be found.
|
||||
}
|
||||
|
||||
func void test4()
|
||||
{
|
||||
An1 an;
|
||||
an.x.@y; // #error: '@' should only be placed in front of macro names
|
||||
}
|
||||
|
||||
func void test5()
|
||||
{
|
||||
An1 an;
|
||||
an.x.@y(); // #error: '@' should only be placed in front of macro names
|
||||
}
|
||||
Reference in New Issue
Block a user