-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
$ENV{"DALE_TEST_ARGS"} ||= ""; | ||
my $test_dir = $ENV{"DALE_TEST_DIR"} || "."; | ||
$ENV{PATH} .= ":."; | ||
|
||
use Data::Dumper; | ||
use Test::More tests => 3; | ||
|
||
my @res = `dalec $ENV{"DALE_TEST_ARGS"} $test_dir/t/src/up-move.dt -o up-move `; | ||
is_deeply(\@res, [], 'No compilation errors'); | ||
@res = `./up-move`; | ||
is($?, 0, 'Program executed successfully'); | ||
|
||
chomp for @res; | ||
|
||
is_deeply(\@res, [ | ||
'100 0 0', | ||
'0 100 0', | ||
'0 0 100', | ||
], | ||
'Got correct results'); | ||
|
||
`rm up-move`; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(import cstdio) | ||
(import macros) | ||
(import unique-ptr) | ||
|
||
(std.concepts.instantiate UniquePtr int) | ||
|
||
(def main | ||
(fn extern-c int (void) | ||
(let ((myptr (UniquePtr int)) | ||
(myptr2 (UniquePtr int)) | ||
(myptr3 (UniquePtr int)) | ||
(myint \ (malloc' 1 int))) | ||
(setf myint 100) | ||
(init myptr myint) | ||
(printf "%d %d %d\n" (@ myptr) | ||
(cast (get myptr2) intptr) | ||
(cast (get myptr3) intptr)) | ||
(setv myptr2 (move myptr)) | ||
(printf "%d %d %d\n" (cast (get myptr) intptr) | ||
(@ myptr2) | ||
(cast (get myptr3) intptr)) | ||
(setv myptr3 (move myptr2)) | ||
(printf "%d %d %d\n" (cast (get myptr) intptr) | ||
(cast (get myptr2) intptr) | ||
(@ myptr3)) | ||
0))) |