-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Java mocking #2024
Open
cassidywaldrip
wants to merge
92
commits into
dafny-lang:master
Choose a base branch
from
byu-dafny:merge-mocking-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 79 commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
da26977
Add devcontainer for vscode
ericmercer e783f00
Remove the pre-commit hook installation
ericmercer 5709c42
Add /generateTestBoogie command to elegantly print boogie
matt4530 c4112b9
Separate modifications into different files
matt4530 82ccbd9
Flush output to dump entire boogie string instead of just 2kb.
matt4530 20ddd04
revert comments
matt4530 74acfa1
Merge pull request #1 from UnknownGuardian/byu-dafny
ericmercer aa1cdcb
Mocking for {:test} attribute
Dargones 7ab10f0
Fix accidental change
Dargones c307c4e
A different test and a fix
Dargones 4300897
fix(semanticCommit): learning new things every day also removed that …
Dargones a3405f7
fix: making the pr semantic
Dargones a832b13
Merge branch 'dafny-lang:master' into counterexamples
Dargones b6e2df4
Mocks using extern
Dargones f61a3a3
Dummy commit
Dargones 9648bb6
Merge branch 'dafny-lang:master' into testFrameworkCSharp
Dargones 9d69721
Mocking First Steps
Dargones 58c47ba
Basic Argument Matching
Dargones c9fab47
Mock Fields
Dargones bf8ab5f
MockWriter class
Dargones 6f5c75b
Merge branch 'dafny-lang:master' into testFrameworkCSharp
Dargones 2237bd3
Improve Readability
Dargones e96574e
Merge branch 'testFrameworkCSharp' of https://github.com/Dargones/daf…
Dargones dbe04a0
Merge branch 'dafny-lang:master' into testFrameworkCSharp
Dargones 1b20628
Compiler style changes
Dargones 67bb487
Merge branch 'testFrameworkCSharp' of https://github.com/Dargones/daf…
Dargones d643d70
More tests
Dargones 1eddfc7
Unique Identifiers
Dargones e812b43
Arbitrary Argument Order
Dargones 5f4aa99
More detailed documentation
Dargones 28df976
compileMocks attribute
Dargones 1af8f55
CrossReferencing
Dargones de0945f
Add basic support for mocking in Java
cassidywaldrip 651b360
inject xunit method source glue code
tbean79 22772ea
Merge branch 'testFrameworkCSharp' of https://github.com/Dargones/daf…
tbean79 5ea83e0
Performance and code style
Dargones a251c4c
Move mockign to separate file
Dargones 3493053
List import fix
Dargones 52dcf8e
Merge branch 'master' into testFrameworkCSharp
keyboardDrummer 361dd56
compiles param tests to java
tbean79 33625f4
name structure converter dependent on method name
tbean79 b1244f2
Merge branch 'testFrameworkCSharp' of https://github.com/Dargones/daf…
tbean79 2551cd2
Merge branch 'paramTests' of https://github.com/Dargones/dafny into p…
tbean79 e4116c0
Add support for Java mocking
cassidywaldrip cf3b1cb
Merge branch 'java-mocks' of https://github.com/Dargones/dafny into j…
tbean79 0949bc3
add documentation and styling
tbean79 a3e1e7a
inject test annotation for java
tbean79 0f50c74
use whitespace
tbean79 1c202bd
Merge pull request #10 from byu-dafny/paramTests
tbean79 7b8780e
update dotnet version
tbean79 8ed8a08
Merge branch 'master' into java-mocks
tbean79 260f7c3
Merge pull request #9 from byu-dafny/java-mocks
tbean79 ce3155b
qualify console var
tbean79 de9ea45
downgrade dotnet version
tbean79 39516ce
update attr docs
tbean79 f0b61ed
remove global.json
tbean79 8948da3
make param docs clearer
tbean79 eebea9c
fix underscore names
tbean79 f0cfb42
Merge pull request #11 from byu-dafny/fix-underscores
tbean79 e58560d
Delete unneccessary comment
cassidywaldrip 3fbe9b6
Fix merge conflicts
cassidywaldrip 67fcc38
Add support for fresh
cassidywaldrip 469d5fd
Pass in mock or fresh as arguments
cassidywaldrip 724a22f
omit param test code
tbean79 40e8932
Clean up files
cassidywaldrip 05b61d9
Merge branch 'merge-mocking-changes' of github.com:byu-dafny/dafny in…
cassidywaldrip 650345a
Update Source/Dafny/Compilers/Compiler-python.cs
cassidywaldrip 0735512
Update Source/Dafny/Compilers/Synthesizer-Java.cs
cassidywaldrip 71e57e6
Get up to date with Dafny
cassidywaldrip 666174c
Fix TestGenerationOptions
cassidywaldrip 341a42e
Remove unnecessary comment in Compiler-Csharp.cs
cassidywaldrip 987de0c
Update Compiler-cpp.cs
cassidywaldrip a526e4d
Remove unnecessary comment in Compiler-go.cs
cassidywaldrip 9bd1499
Remove unnecessary comment in Compiler-js.cs
cassidywaldrip 5aa376a
Update Source/Dafny/Compilers/SinglePassCompiler.cs
cassidywaldrip b5ecf63
Add fresh to C#
cassidywaldrip 5026caa
Add mock and fresh annotations to unit tests
cassidywaldrip 7a66575
Merge remote-tracking branch 'origin/master' into merge-mocking-changes
cassidywaldrip 9b6b2fb
Remove devcontainer, complete requested changes
cassidywaldrip be0b653
Get up to date with master
cassidywaldrip 0016a75
Merge pull request #12 from dafny-lang/master
cassidywaldrip 04da7c4
Change from mocks to spys
cassidywaldrip eb491e8
Merge branch 'master' into merge-mocking-changes
cassidywaldrip 90eded1
Merge branch 'master' into merge-mocking-changes
cassidywaldrip 5bb3719
Merge branch 'dafny-lang:master' into master
cassidywaldrip b8681f1
Merge branch 'master' into merge-mocking-changes
cassidywaldrip 938d7f5
Merge branch 'dafny-lang:master' into master
cassidywaldrip e2b9c91
Merge branch 'merge-mocking-changes' of github.com:byu-dafny/dafny in…
cassidywaldrip ec88434
Get merge-mocking-changes up to date with master
cassidywaldrip ee85070
Make requested changes
cassidywaldrip 0ca44d7
Add Synthesizer base class
cassidywaldrip d7def3b
Remove synthesis from Java unsupported features
cassidywaldrip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# find the source directory for this script even if it's been symlinked [issue #185] | ||
# from https://stackoverflow.com/questions/59895/ | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" | ||
done | ||
DAFNY_ROOT="$( cd -P "$( dirname $( dirname "$SOURCE" ))" && pwd )" | ||
|
||
cd $DAFNY_ROOT | ||
# pre-commit install | ||
npm install bignumber.js | ||
cd $DAFNY_ROOT/Binaries | ||
ln -s /opt/z3/z3-4.8.5-x64-ubuntu-16.04/ z3 | ||
cassidywaldrip marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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
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
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 |
---|---|---|
|
@@ -114,6 +114,7 @@ public override void OnPostCompile() { | |
protected interface IClassWriter { | ||
ConcreteSyntaxTree/*?*/ CreateMethod(Method m, List<TypeArgumentInstantiation> typeArgs, bool createBody, bool forBodyInheritance, bool lookasideBody); | ||
ConcreteSyntaxTree/*?*/ SynthesizeMethod(Method m, List<TypeArgumentInstantiation> typeArgs, bool createBody, bool forBodyInheritance, bool lookasideBody); | ||
ConcreteSyntaxTree/*?*/ CreateFreshMethod(Method m); | ||
ConcreteSyntaxTree/*?*/ CreateFunction(string name, List<TypeArgumentInstantiation> typeArgs, List<Formal> formals, Type resultType, Bpl.IToken tok, bool isStatic, bool createBody, | ||
MemberDecl member, bool forBodyInheritance, bool lookasideBody); | ||
ConcreteSyntaxTree/*?*/ CreateGetter(string name, TopLevelDecl enclosingDecl, Type resultType, Bpl.IToken tok, bool isStatic, bool isConst, bool createBody, MemberDecl/*?*/ member, bool forBodyInheritance); // returns null iff !createBody | ||
|
@@ -1406,6 +1407,10 @@ public ConcreteSyntaxTree SynthesizeMethod(Method m, List<TypeArgumentInstantiat | |
throw new UnsupportedFeatureException(m.tok, Feature.MethodSynthesis); | ||
} | ||
|
||
public ConcreteSyntaxTree CreateFreshMethod(Method m) { | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public ConcreteSyntaxTree/*?*/ CreateFunction(string name, List<TypeArgumentInstantiation> typeArgs, List<Formal> formals, Type resultType, Bpl.IToken tok, bool isStatic, bool createBody, MemberDecl member, bool forBodyInheritance, bool lookasideBody) { | ||
return createBody ? block : null; | ||
} | ||
|
@@ -1918,18 +1923,34 @@ void CompileClassMembers(Program program, TopLevelDeclWithMembers c, IClassWrite | |
v.Visit(f); | ||
} else if (member is Method m) { | ||
if (Attributes.Contains(m.Attributes, "synthesize")) { | ||
if (m.IsStatic && m.Outs.Count > 0 && m.Body == null) { | ||
classWriter.SynthesizeMethod(m, CombineAllTypeArguments(m), true, true, false); | ||
} else { | ||
Error(m.tok, "Method {0} is annotated with :synthesize but " + | ||
var args = Attributes.FindExpressions(m.Attributes, "synthesize"); | ||
if (args != null && (string)(args[0] as StringLiteralExpr)?.Value == "mock") { | ||
if (m.IsStatic && m.Outs.Count > 0 && m.Body == null) { | ||
classWriter.SynthesizeMethod(m, CombineAllTypeArguments(m), true, true, false); | ||
} else { | ||
Error(m.tok, "Method {0} is annotated with :synthesize but " + | ||
"is not static, has a body, or does not return " + | ||
"anything", | ||
errorWr, m.FullName); | ||
} | ||
} else if (args != null && (string)(args[0] as StringLiteralExpr)?.Value == "fresh") { | ||
if (m.IsStatic && m.Outs.Count > 0 && m.Body == null) { | ||
classWriter.CreateFreshMethod(m); | ||
} else { | ||
Error(m.tok, "Method {0} is annotated with :synthesize but " + | ||
"is not static, has a body, or does not return " + | ||
"anything", | ||
errorWr, m.FullName); | ||
} | ||
} else { | ||
Error(m.tok, "Method {0} is annotated with :synthesize but " + | ||
"does not have the required parameters", | ||
errorWr, m.FullName); | ||
} | ||
} else if (m.Body == null && !(c is TraitDecl && !m.IsStatic) && | ||
!(!DafnyOptions.O.DisallowExterns && (Attributes.Contains(m.Attributes, "dllimport") || (IncludeExternMembers && Attributes.Contains(m.Attributes, "extern"))))) { | ||
// A (ghost or non-ghost) method must always have a body, except if it's an instance method in a trait. | ||
if (Attributes.Contains(m.Attributes, "axiom") || (!DafnyOptions.O.DisallowExterns && Attributes.Contains(m.Attributes, "extern"))) { | ||
if (Attributes.Contains(m.Attributes, "axiom")) { | ||
// suppress error message | ||
} else { | ||
Error(m.tok, "Method {0} has no body", errorWr, m.FullName); | ||
|
@@ -2823,7 +2844,7 @@ void TrStmtNonempty(Statement stmt, ConcreteSyntaxTree wr) { | |
protected internal void TrStmt(Statement stmt, ConcreteSyntaxTree wr) { | ||
Contract.Requires(stmt != null); | ||
Contract.Requires(wr != null); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep that line. |
||
if (stmt.IsGhost) { | ||
return; | ||
} | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure?