-
Notifications
You must be signed in to change notification settings - Fork 269
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
fix: Use the right >/</>=/<= comparison operators for bitvectors in JS #2716
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
447f888
fix: Use the right >/</>=/<= comparison operators for bitvectors in JS
cpitclaudel 0421f12
fix: Use the right comparison operators for ordinals in Go
cpitclaudel e929451
Merge remote-tracking branch 'origin/master' into cpitclaudel_fix-2672
cpitclaudel be66cdf
Work around a C++ compiler bug (#2773)
cpitclaudel 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
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,100 @@ | ||
// RUN: %dafny /compile:0 "%s" > "%t" | ||
// RUN: %dafny /noVerify /compile:4 /compileTarget:cs "%s" >> "%t" | ||
// RUN: %dafny /noVerify /compile:4 /compileTarget:js "%s" >> "%t" | ||
// RUN: %dafny /noVerify /compile:4 /compileTarget:go "%s" >> "%t" | ||
// RUN: %dafny /noVerify /compile:4 /compileTarget:java "%s" >> "%t" | ||
// RUN: %dafny /noVerify /compile:4 /compileTarget:py "%s" >> "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
newtype sreal = r: real | r > -4 as real | ||
newtype sint = r: int | r > -4 as int | ||
newtype ssreal = r: sreal | r > -3 as sreal | ||
newtype ssint = r: sint | r > -3 as sint | ||
|
||
method Print(b: bool, end: string) | ||
// Print boolean `b` as `true` or `false`, then print `end`. This is needed | ||
// by C++ due to BUG(https://github.com/dafny-lang/dafny/issues/2773). | ||
{ | ||
if b { | ||
print "true"; | ||
} else { | ||
print "false"; | ||
} | ||
print end; | ||
} | ||
|
||
method Main() { | ||
Print(24 as real <= 1507 as real, " "); | ||
Print(24 as sreal <= 1507 as sreal, " "); | ||
Print(24 as ssreal <= 1507 as ssreal, " "); | ||
Print(24 as int <= 1507 as int, " "); | ||
Print(24 as sint <= 1507 as sint, " "); | ||
Print(24 as ssint <= 1507 as ssint, " "); | ||
Print(24 as bv16 <= 1507 as bv16, " "); | ||
Print(24 as bv232 <= 1507 as bv232, " "); | ||
Print(24 as char <= 1507 as char, " "); | ||
Print(24 as ORDINAL <= 1507 as ORDINAL, "\n"); | ||
|
||
Print(24 as real == 1507 as real, " "); | ||
Print(24 as sreal == 1507 as sreal, " "); | ||
Print(24 as ssreal == 1507 as ssreal, " "); | ||
Print(24 as int == 1507 as int, " "); | ||
Print(24 as sint == 1507 as sint, " "); | ||
Print(24 as ssint == 1507 as ssint, " "); | ||
Print(24 as bv16 == 1507 as bv16, " "); | ||
Print(24 as bv232 == 1507 as bv232, " "); | ||
Print(24 as char == 1507 as char, " "); | ||
Print(24 as ORDINAL == 1507 as ORDINAL, "\n"); | ||
|
||
Print(24 as real >= 1507 as real, " "); | ||
Print(24 as sreal >= 1507 as sreal, " "); | ||
Print(24 as ssreal >= 1507 as ssreal, " "); | ||
Print(24 as int >= 1507 as int, " "); | ||
Print(24 as sint >= 1507 as sint, " "); | ||
Print(24 as ssint >= 1507 as ssint, " "); | ||
Print(24 as bv16 >= 1507 as bv16, " "); | ||
Print(24 as bv232 >= 1507 as bv232, " "); | ||
Print(24 as char >= 1507 as char, " "); | ||
Print(24 as ORDINAL >= 1507 as ORDINAL, "\n"); | ||
|
||
Print(24 as real < 1507 as real, " "); | ||
Print(24 as sreal < 1507 as sreal, " "); | ||
Print(24 as ssreal < 1507 as ssreal, " "); | ||
Print(24 as int < 1507 as int, " "); | ||
Print(24 as sint < 1507 as sint, " "); | ||
Print(24 as ssint < 1507 as ssint, " "); | ||
Print(24 as bv16 < 1507 as bv16, " "); | ||
Print(24 as bv232 < 1507 as bv232, " "); | ||
Print(24 as char < 1507 as char, " "); | ||
Print(24 as ORDINAL < 1507 as ORDINAL, "\n"); | ||
|
||
Print(24 as real != 1507 as real, " "); | ||
Print(24 as sreal != 1507 as sreal, " "); | ||
Print(24 as ssreal != 1507 as ssreal, " "); | ||
Print(24 as int != 1507 as int, " "); | ||
Print(24 as sint != 1507 as sint, " "); | ||
Print(24 as ssint != 1507 as ssint, " "); | ||
Print(24 as bv16 != 1507 as bv16, " "); | ||
Print(24 as bv232 != 1507 as bv232, " "); | ||
Print(24 as char != 1507 as char, " "); | ||
Print(24 as ORDINAL != 1507 as ORDINAL, "\n"); | ||
|
||
Print(24 as real > 1507 as real, " "); | ||
Print(24 as sreal > 1507 as sreal, " "); | ||
Print(24 as ssreal > 1507 as ssreal, " "); | ||
Print(24 as int > 1507 as int, " "); | ||
Print(24 as sint > 1507 as sint, " "); | ||
Print(24 as ssint > 1507 as ssint, " "); | ||
Print(24 as bv16 > 1507 as bv16, " "); | ||
Print(24 as bv232 > 1507 as bv232, " "); | ||
Print(24 as char > 1507 as char, " "); | ||
Print(24 as ORDINAL > 1507 as ORDINAL, "\n"); | ||
|
||
Print(0 as bv0 <= 0 as bv0, " "); | ||
Print(0 as bv0 == 0 as bv0, " "); | ||
Print(0 as bv0 >= 0 as bv0, "\n"); | ||
|
||
Print(0 as bv0 < 0 as bv0, " "); | ||
Print(0 as bv0 != 0 as bv0, " "); | ||
Print(0 as bv0 > 0 as bv0, "\n"); | ||
} |
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,52 @@ | ||
|
||
Dafny program verifier finished with 5 verified, 0 errors | ||
|
||
Dafny program verifier did not attempt verification | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
false false false false false false false false false false | ||
true true true true true true true true true true | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
true true true | ||
false false false | ||
|
||
Dafny program verifier did not attempt verification | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
false false false false false false false false false false | ||
true true true true true true true true true true | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
true true true | ||
false false false | ||
|
||
Dafny program verifier did not attempt verification | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
false false false false false false false false false false | ||
true true true true true true true true true true | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
true true true | ||
false false false | ||
|
||
Dafny program verifier did not attempt verification | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
false false false false false false false false false false | ||
true true true true true true true true true true | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
true true true | ||
false false false | ||
|
||
Dafny program verifier did not attempt verification | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
false false false false false false false false false false | ||
true true true true true true true true true true | ||
true true true true true true true true true true | ||
false false false false false false false false false false | ||
true true true | ||
false false false |
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.
Can you use
%testDafnyForEachCompiler %s
instead? :)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.
Can you remind me how to generate the output with that flag?
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.
It should just be a single copy of the program's output, not including the "Dafny program verifier ..." line. So in this case just:
It occurs to me that having a flag on the
TestDafny
tool to generate the expect file would be super handy, let meknowsee if I can add that. :)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.
Thanks! Unfortunately it doesn't correctly detect unsupported features, so it fails on this example; I've reported the error at #2718 , and I'm currently preparing a PR. We can update this test file once that PR is merged, but I don't think we need to block on it.
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.
I'm not sure we should add the output generation to TestDafny, btw, since it's needed for all lit tests (not just for
for-each-compiler
). Maybe we could updaterunTest.py
to recognize that case in addition to the usual diff-based ones.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.
I think both makes sense. Since LIT tests can be more complicated than just piping to a single
*.expect
file,runTest.py
can't realistically generate the "expected output" for an arbitrary LIT test (nor would this make sense as a feature on the xUnit-based LIT test runner either). I say we update it to recognize%testDafnyForEachCompiler
but have it delegate generating the output file toTestDafny
.Part of the reason I'd prefer that is I'd also find it useful to install
testdafny
as a local dotnet tool and run it in this mode on arbitrary source files as part of development.