mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Fix issue where a compile time parameter is followed by "...".
- Fix issue with some conversions to untyped list. - Experimental change: add `+++` `&&&` `|||` as replacement for `$concat`, `$and` and `$or`.
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
module test;
|
||||
macro foo()
|
||||
{
|
||||
var c = $concat("hello", " world");
|
||||
String[*] a = $concat(String[1] { "hello" }, String[1] { " world" });
|
||||
var c = "hello" +++ " world";
|
||||
String[*] a = String[1] { "hello" } +++ String[1] { " world" };
|
||||
int[2] $a = { 1, 2 };
|
||||
$a = $append($a, 100);
|
||||
$a = $a +++ 100;
|
||||
int z = $typeof($a).len;
|
||||
var b = $a;
|
||||
var d = $append(int[]{}, 1, 2, 3);
|
||||
var e = $append(String[1] { "hello... " }, " there!");
|
||||
var f = $concat("", "");
|
||||
var g = $concat("bye");
|
||||
var d = int[]{} +++ 1 +++ 2 +++ 3;
|
||||
var e = String[1] { "hello... " } +++ " there!";
|
||||
var f = "" +++ "";
|
||||
var g = "bye";
|
||||
var h = $$str_hash("helloworld");
|
||||
}
|
||||
fn int main()
|
||||
|
||||
25
test/test_suite/compile_time/concat_test_cases.c3
Normal file
25
test/test_suite/compile_time/concat_test_cases.c3
Normal file
@@ -0,0 +1,25 @@
|
||||
fn void main(String[] args)
|
||||
{
|
||||
var $x = int[2]{ 1, 2 } +++ int[2]{ 4, 5 };
|
||||
var $v = "foo" +++ "baz" +++ '!' +++ '?';
|
||||
var $b = x'403322' +++ "baz";
|
||||
var $b2 = x'40334a' +++ 55 +++ 55;
|
||||
var $b3 = x'403322' +++ char[2] { 1, 2 };
|
||||
var $b4 = x'403322' +++ char[2] { 1, 2 };
|
||||
var $b5 = "foo" +++ { 55, 57 };
|
||||
var $b6 = ((ichar[3])x'403322') +++ ichar[2] { 1, 2 };
|
||||
var $b7 = char[2] { 1, 2 } +++ "foo";
|
||||
assert($b7 == { 1, 2, 102, 111, 111});
|
||||
assert($b5 == "foo79");
|
||||
assert($b3 == $b4);
|
||||
assert($b6 == { 0x40, 0x33, 0x22, 1, 2 });
|
||||
int[4] $x2 = int[2]{ 1, 2 }+++ int[2]{ 4, 5 };
|
||||
int[4] $y = { 1, 2 } +++ { 4, 5 };
|
||||
assert($x == {1, 2, 4, 5});
|
||||
assert($x2 == {1, 2, 4, 5});
|
||||
assert($y == {1, 2, 4, 5});
|
||||
assert($v == "foobaz!?");
|
||||
assert($b == {64, 51, 34, 98, 97, 122});
|
||||
assert($b2 == {64, 51, 74, 55, 55});
|
||||
assert($b3 == {64, 51, 34, 1, 2});
|
||||
}
|
||||
@@ -10,3 +10,5 @@ fn void foo4($Type) { } // #error: Only regular parameters are allowed for funct
|
||||
fn void foo8(int* &foo) {} // #error: Only regular parameters are allowed for functions.
|
||||
|
||||
fn void foo9(int x, int x) {} // #error: Duplicate parameter name 'x'.
|
||||
|
||||
macro @foo($a, $b, $c, ...) {}
|
||||
Reference in New Issue
Block a user