-
Notifications
You must be signed in to change notification settings - Fork 783
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
Moved CodeGen/EmittedIL/LiteralValue over to NUnit #7291
Conversation
let ``Literal Value``() = | ||
CompilerAssert.CompileLibraryAndVerifyIL | ||
""" | ||
module LiteralValue |
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.
@TIHan I have to add module
line and rename arg
to _
to make this test works.
It is OK that CompilerAssert.CompileLibraryAndVerifyIL
require source code to compile without warnings?
.method public static int32 main(string[] _arg1) cil managed | ||
{ | ||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.EntryPointAttribute::.ctor() = ( 01 00 00 00 ) | ||
|
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.
In general I do not like that we remove comments from emitted IL code
fsharp/tests/fsharp/Compiler/ILChecker.fs
Lines 46 to 54 in 8209f2f
let textNoComments = | |
System.Text.RegularExpressions.Regex.Replace(text, | |
blockComments + "|" + lineComments + "|" + strings + "|" + verbatimStrings, | |
(fun me -> | |
if (me.Value.StartsWith("/*") || me.Value.StartsWith("//")) then | |
if me.Value.StartsWith("//") then Environment.NewLine else String.Empty | |
else | |
me.Value), System.Text.RegularExpressions.RegexOptions.Singleline) | |
|> filterSpecialComment |
and do not do it for
expectedIL
samples.
In this test I have to remove all comments manually.
Can we apply the same transformation to emitted and expected IL? What do think @TIHan ?
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.
This is necessary since some tools (ILDasm?) add comments such that you cannot verify IL emitted by the compiler. This was necessary for string concat optimization work I believe.
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.
@cartermp I got it, but I think that would be nice to allow copy generated IL from ILDasm and use it in test directly (without manual comments removal).
Then test framework (inside verifier.VerifyIL
):
- compile code sample and generate IL using
ILDASM
- remove comments from IL produced in step
1
(like it does now) - remove comments from expected IL specified in using test, the same transformation that we do in step
2
(I propose) - compare two set of IL instructions from
2
&3
benefits: less manual work to cleanup expected IL
(ability to use snippet from ILDasm).
This PR should be ready for review (if tests pass).
|
Because of these errors on
|
* Moved CodeGen/EmittedIL/LiteralValue over to NUnit * Expected IL simplified to test one thing and to be runtime independent
part of #7075