File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,15 @@ public record class ParserOptions
1414
1515 public ScannerOptions GetScannerOptions ( ) => _scannerOptions ;
1616
17+ protected ParserOptions ( ParserOptions original )
18+ {
19+ _scannerOptions = original . _scannerOptions with { } ;
20+ Tokens = original . Tokens ;
21+ AllowReturnOutsideFunction = original . AllowReturnOutsideFunction ;
22+ MaxAssignmentDepth = original . MaxAssignmentDepth ;
23+ OnNodeCreated = original . OnNodeCreated ;
24+ }
25+
1726 /// <summary>
1827 /// Gets or sets whether the tokens are included in the parsed tree, defaults to <see langword="false"/>.
1928 /// </summary>
Original file line number Diff line number Diff line change 1+ namespace Esprima . Tests ;
2+
3+ public class ParserOptionsTests
4+ {
5+ [ Fact ]
6+ public void CopyCtorShouldCreateDeepClone ( )
7+ {
8+ var options1 = new ParserOptions { Tolerant = false } ;
9+ var options2 = options1 with { Tolerant = true } ;
10+
11+ Assert . NotSame ( options1 . GetScannerOptions ( ) , options2 . GetScannerOptions ( ) ) ;
12+ Assert . True ( options2 . Tolerant ) ;
13+ Assert . False ( options1 . Tolerant ) ;
14+ }
15+
16+ [ Fact ]
17+ public void EqualsShouldCheckStructuralEquality ( )
18+ {
19+ var options1 = new ParserOptions { Tolerant = false } ;
20+ var options2 = options1 with { Tolerant = false } ;
21+
22+ Assert . NotSame ( options1 . GetScannerOptions ( ) , options2 . GetScannerOptions ( ) ) ;
23+ Assert . Equal ( options1 . GetScannerOptions ( ) , options2 . GetScannerOptions ( ) ) ;
24+ Assert . Equal ( options1 , options2 ) ;
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments