forked from sebastienros/esprima-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix copy ctor of ParserOptions (default implementation doesn't deep c…
…lone record type fields) (sebastienros#436)
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
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,26 @@ | ||
namespace Esprima.Tests; | ||
|
||
public class ParserOptionsTests | ||
{ | ||
[Fact] | ||
public void CopyCtorShouldCreateDeepClone() | ||
{ | ||
var options1 = new ParserOptions { Tolerant = false }; | ||
var options2 = options1 with { Tolerant = true }; | ||
|
||
Assert.NotSame(options1.GetScannerOptions(), options2.GetScannerOptions()); | ||
Assert.True(options2.Tolerant); | ||
Assert.False(options1.Tolerant); | ||
} | ||
|
||
[Fact] | ||
public void EqualsShouldCheckStructuralEquality() | ||
{ | ||
var options1 = new ParserOptions { Tolerant = false }; | ||
var options2 = options1 with { Tolerant = false }; | ||
|
||
Assert.NotSame(options1.GetScannerOptions(), options2.GetScannerOptions()); | ||
Assert.Equal(options1.GetScannerOptions(), options2.GetScannerOptions()); | ||
Assert.Equal(options1, options2); | ||
} | ||
} |