Skip to content

Commit

Permalink
Log two new first class procedure tests (#26214)
Browse files Browse the repository at this point in the history
These tests are based off of #18413, though updated for the new syntax
for FCPs (based on the deprecation warnings I encountered when trying to
compile them).  One of them is a future due to the bug still being present.

A fresh checkout of the tests behaved as expected
  • Loading branch information
lydia-duncan authored Nov 12, 2024
2 parents fd297ff + e56519a commit 4cf95ab
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/functions/fcf/assignInIfExpr.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assignInIfExpr.chpl:6: syntax error: near '{'
7 changes: 7 additions & 0 deletions test/functions/fcf/assignInIfExpr.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// code from https://github.com/chapel-lang/chapel/issues/18413, note that
// it did not compile then either, though at a later point in compilation
var isHammingWeightFixed: bool = true;

var projFn = if isHammingWeightFixed
then proc(x) { return x; }
else proc(x) { return x; };
2 changes: 2 additions & 0 deletions test/functions/fcf/assignInIfExpr.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bug: syntax error when assigning fcf via an if expression
#18413
Empty file.
11 changes: 11 additions & 0 deletions test/functions/fcf/assignLater.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
config var isHammingWeightFixed: bool = true;

var projFn: proc(x:int): int;

if isHammingWeightFixed {
projFn = proc(x:int) { return x; };
} else {
projFn = proc(x:int) { return x+1; };
}

writeln(projFn(1));
1 change: 1 addition & 0 deletions test/functions/fcf/assignLater.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit 4cf95ab

Please sign in to comment.