-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug in typechecking and add regression tests.
- Loading branch information
Showing
4 changed files
with
82 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use datapond_derive::datapond; | ||
|
||
fn test1() { | ||
let inp = vec![(1, 2, 0), (2, 3, 0)]; | ||
let out; | ||
datapond! { | ||
input inp(x: u32, y: u32, z: u32) | ||
output out(x: u32, y: u32) | ||
out(x, y) :- inp(.y=y, .y=x). | ||
}; | ||
assert_eq!(out.len(), 2); | ||
} | ||
|
||
fn test2() { | ||
let inp = vec![(1, 2, 0), (2, 3, 0)]; | ||
let out; | ||
datapond! { | ||
input inp(x: u32, y: u32, z: u32) | ||
output out(x: u32, y: u32) | ||
out(x, y) :- inp(.a=y, .y=x). | ||
}; | ||
assert_eq!(out.len(), 2); | ||
} | ||
|
||
fn main() { | ||
test1(); | ||
test2(); | ||
} |
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,11 @@ | ||
error: Parameter already bound: y | ||
--> $DIR/kwargs.rs:9:33 | ||
| | ||
9 | out(x, y) :- inp(.y=y, .y=x). | ||
| ^ | ||
|
||
error: Unknown parameter a in predicate inp. Available parameters are: x,y,z. | ||
--> $DIR/kwargs.rs:20:27 | ||
| | ||
20 | out(x, y) :- inp(.a=y, .y=x). | ||
| ^ |
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,23 @@ | ||
use datapond_derive::datapond; | ||
|
||
fn main() { | ||
let inp = vec![(1, 2, 0), (2, 3, 0)]; | ||
let out; | ||
let out2; | ||
datapond! { | ||
input inp(x: u32, y: u32, z: u32) | ||
|
||
output out(x: u32, y: u32) | ||
out(x, y) :- inp(.y=y, .x=x). | ||
|
||
output out2(x: u32, y: u32) | ||
out2(a, b) :- inp(.y=a, .x=b). | ||
}; | ||
assert_eq!(out.len(), 2); | ||
assert_eq!(out[0], (1, 2)); | ||
assert_eq!(out[1], (2, 3)); | ||
|
||
assert_eq!(out2.len(), 2); | ||
assert_eq!(out2[0], (2, 1)); | ||
assert_eq!(out2[1], (3, 2)); | ||
} |
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