Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardDrummer committed Sep 20, 2024
1 parent 535aa54 commit 39b7daa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ public NestedMatchStmt(Cloner cloner, NestedMatchStmt original) : base(cloner, o

public override IEnumerable<INode> Children => new[] { Source }.Concat<Node>(Cases);

public override IEnumerable<Statement> SubStatements => Cases.SelectMany(c => c.Body);
public override IEnumerable<Statement> SubStatements {
get {
if (Flattened != null) {
return Flattened.SubStatements;
}
return Cases.SelectMany(c => c.Body);
}
}

public override IEnumerable<Statement> PreResolveSubStatements {
get => this.Cases.SelectMany(oneCase => oneCase.Body);
Expand Down
7 changes: 6 additions & 1 deletion Source/DafnyDriver/CliCompilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ public static string DescribeOutcome(VcOutcome outcome) {
private List<ICanVerify> FilterCanVerifies(List<ICanVerify> canVerifies, out int? line) {
var symbolFilter = Options.Get(VerifyCommand.FilterSymbol);
if (symbolFilter != null) {
canVerifies = canVerifies.Where(canVerify => canVerify.FullDafnyName.Contains(symbolFilter)).ToList();
if (symbolFilter.EndsWith(".")) {
var withoutDot = new string(symbolFilter.SkipLast(1).ToArray());
canVerifies = canVerifies.Where(canVerify => canVerify.FullDafnyName.EndsWith(withoutDot)).ToList();
} else {
canVerifies = canVerifies.Where(canVerify => canVerify.FullDafnyName.Contains(symbolFilter)).ToList();
}
}

var filterPosition = Options.Get(VerifyCommand.FilterPosition);
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyDriver/Commands/VerifyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static VerifyCommand() {
IsHidden = true
};
public static readonly Option<string> FilterSymbol = new("--filter-symbol",
@"Filter what gets verified by selecting only symbols whose fully qualified name contains the given argument. For example: ""--filter-symbol=MyNestedModule.MyFooFunction""");
@"Filter what gets verified by selecting only symbols whose fully qualified name contains the given argument, for example: ""--filter-symbol=MyNestedModule.MyFooFunction"". Place a dot at the end of the argument to indicate the symbol name must end like this, which can be useful if one symbol name is a prefix of another.");

public static readonly Option<string> FilterPosition = new("--filter-position",
@"Filter what gets verified based on a source location. The location is specified as a file path suffix, optionally followed by a colon and a line number. For example, `dafny verify dfyconfig.toml --filter-position=source1.dfy:5` will only verify things that range over line 5 in the file `source1.dfy`. In combination with `--isolate-assertions`, individual assertions can be verified by filtering on the line that contains them. When processing a single file, the filename can be skipped, for example: `dafny verify MyFile.dfy --filter-position=:23`");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,19 @@ method MultipleAssignment() returns (r: int) {
x, y := tuple.0, tuple.1;
}
r := x;
}

method FlattenedMatch(x: Option<int>, y: Option<int>) {
// This match statement must copy some of the case bodies when flattening
var z := 3;
opaque {
match (x, y) {
case (Some(a), _) =>
var y := a;
case (_, Some(b)) =>
var z := b;
case _ =>
}
}
assert z == 3;
}

0 comments on commit 39b7daa

Please sign in to comment.