Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Run these tasks even if eponymous files or folders exist
.PHONY: test-dafny exe

DIR=$(realpath $(dir $(firstword $(MAKEFILE_LIST))))

default: exe
Expand Down Expand Up @@ -30,6 +33,24 @@ tests:
test:
(cd "${DIR}"; dotnet test Source/IntegrationTests --filter "DisplayName~${name}")

# Run Dafny on an integration test case directly in the folder itself.
# make test-run name=<part of the path> action="run ..."
test-dafny:
name="$(name)"; \
files=$$(cd "${DIR}"/Source/IntegrationTests/TestFiles/LitTests/LitTest; find . -type f -wholename "*$$name*" | grep -E '\.dfy$$'); \
count=$$(echo "$$files" | wc -l); \
echo "$${files}"; \
if [ "$$count" -eq 0 ]; then \
echo "No files found matching pattern: $$name"; \
exit 1; \
else \
echo "$$count test files found."; \
for file in $$files; do \
filedir=$$(dirname "$$file"); \
(cd "${DIR}/Source/IntegrationTests/TestFiles/LitTests/LitTest/$${filedir}"; "${DIR}"/Binaries/Dafny $(action) "$$(basename $$file)" ); \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking since this doesn't appear to be used for any automation, but I would suggest using dotnet run ... instead of Binaries/Dafny to prevent the mistake of running make test-run ... on an outdated binary.

done; \
fi

tests-verbose:
(cd "${DIR}"; dotnet test --logger "console;verbosity=normal" Source/IntegrationTests )

Expand Down
6 changes: 5 additions & 1 deletion Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,11 @@ module {:extern "DCOMP"} DafnyToRustCompiler {
match op {
case Eq(referential) => {
if (referential) {
r := R.BinaryOp("==", left, right, DAST.Format.BinaryOpFormat.NoFormat());
if pointerType.Raw? {
r := Error("Raw pointer comparison not properly implemented yet (need to make comp/rust/traits.dfy to pass with --raw-pointer)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It seems strange to mention this implementation detail in the error message.

Suggested change
r := Error("Raw pointer comparison not properly implemented yet (need to make comp/rust/traits.dfy to pass with --raw-pointer)");
// Need to make comp/rust/traits.dfy to pass with --raw-pointer)
r := Error("Raw pointer comparison not properly implemented yet");

} else {
r := R.BinaryOp("==", left, right, DAST.Format.BinaryOpFormat.NoFormat());
}
} else {
if rExpr.SeqValue? && |rExpr.elements| == 0 {
r := R.BinaryOp("==", left.Sel("to_array").Apply0().Sel("len").Apply0(), R.LiteralInt("0"), DAST.Format.BinaryOpFormat.NoFormat());
Expand Down
18 changes: 12 additions & 6 deletions Source/DafnyCore/GeneratedFromDafny/DCOMP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,13 @@ public void GenExprBinary(DAST._IExpression e, Defs._ISelfInfo selfIdent, Defs._
bool _14_referential = _source1.dtor_referential;
{
if (_14_referential) {
r = RAST.Expr.create_BinaryOp(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("=="), _8_left, _11_right, DAST.Format.BinaryOpFormat.create_NoFormat());
if (((this).pointerType).is_Raw) {
RAST._IExpr _out6;
_out6 = (this).Error(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("Raw pointer comparison not properly implemented yet (need to make comp/rust/traits.dfy to pass with --raw-pointer)"), (this).InitEmptyExpr());
r = _out6;
} else {
r = RAST.Expr.create_BinaryOp(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("=="), _8_left, _11_right, DAST.Format.BinaryOpFormat.create_NoFormat());
}
} else {
if (((_2_rExpr).is_SeqValue) && ((new BigInteger(((_2_rExpr).dtor_elements).Count)).Sign == 0)) {
r = RAST.Expr.create_BinaryOp(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("=="), ((((_8_left).Sel(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("to_array"))).Apply0()).Sel(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("len"))).Apply0(), RAST.Expr.create_LiteralInt(Dafny.Sequence<Dafny.Rune>.UnicodeFromString("0")), DAST.Format.BinaryOpFormat.create_NoFormat());
Expand Down Expand Up @@ -3254,11 +3260,11 @@ public void GenExprBinary(DAST._IExpression e, Defs._ISelfInfo selfIdent, Defs._
}
}
after_match0: ;
RAST._IExpr _out6;
Defs._IOwnership _out7;
(this).FromOwned(r, expectedOwnership, out _out6, out _out7);
r = _out6;
resultingOwnership = _out7;
RAST._IExpr _out7;
Defs._IOwnership _out8;
(this).FromOwned(r, expectedOwnership, out _out7, out _out8);
r = _out7;
resultingOwnership = _out8;
readIdents = Dafny.Set<Dafny.ISequence<Dafny.Rune>>.Union(_10_recIdentsL, _13_recIdentsR);
return ;
}
Expand Down