@@ -516,6 +516,51 @@ public void ShouldChangeVariableType(string source, string expected)
516
516
Assert . Equal ( expected , rendered ) ;
517
517
}
518
518
519
+ [ Theory ]
520
+ [ InlineData ( "{{ 0 | times: 1 }}" , "0" ) ]
521
+ [ InlineData ( "{{ 0.0 | times: 1 }}" , "0.0" ) ]
522
+ [ InlineData ( "{{ 0.1 | times: 1 }}" , "0.1" ) ]
523
+ [ InlineData ( "{{ 0.01 | times: 1 }}" , "0.01" ) ]
524
+ [ InlineData ( "{{ 0.0123 | times: 1 }}" , "0.0123" ) ]
525
+ [ InlineData ( "{{ 0 | times: 1.0 }}" , "0.0" ) ]
526
+ [ InlineData ( "{{ 1 | times: 1 }}" , "1" ) ]
527
+ [ InlineData ( "{{ 1 | times: 1.1 }}" , "1.1" ) ]
528
+ [ InlineData ( "{{ 1 | times: 1.123 }}" , "1.123" ) ]
529
+ [ InlineData ( "{{ 1 | times: 1.1234567890 }}" , "1.123456789" ) ]
530
+ [ InlineData ( "{{ 1 | times: 1.1000 }}" , "1.1" ) ]
531
+ [ InlineData ( "{{ 1.1000 | times: 1 }}" , "1.1" ) ]
532
+ [ InlineData ( "{{ 1 | times: 1. }}" , "1" ) ]
533
+ public void ShouldPreservePrecision ( string source , string expected )
534
+ {
535
+ var result = _parser . TryParse ( source , out var template , out var errors ) ;
536
+
537
+ Assert . True ( result ) ;
538
+ Assert . NotNull ( template ) ;
539
+ Assert . Null ( errors ) ;
540
+
541
+ var rendered = template . Render ( ) ;
542
+
543
+ Assert . Equal ( expected , rendered ) ;
544
+ }
545
+
546
+ [ Theory ]
547
+ [ InlineData ( "{{ 0. | times: 1 }}" , "0" ) ]
548
+ [ InlineData ( "{{ 0.0 | times: 1.0 }}" , "0.0" ) ]
549
+ [ InlineData ( "{{ 0.00 | times: 1 }}" , "0.0" ) ]
550
+ [ InlineData ( "{{ 0. | times: 1.0 }}" , "0.0" ) ]
551
+ public void DotsAreParsedAsIntegralValues ( string source , string expected )
552
+ {
553
+ var result = _parser . TryParse ( source , out var template , out var errors ) ;
554
+
555
+ Assert . True ( result ) ;
556
+ Assert . NotNull ( template ) ;
557
+ Assert . Null ( errors ) ;
558
+
559
+ var rendered = template . Render ( ) ;
560
+
561
+ Assert . Equal ( expected , rendered ) ;
562
+ }
563
+
519
564
[ Theory ]
520
565
[ InlineData ( "{% assign my_string = 'abcd' %}{{ my_string.size }}" , "4" ) ]
521
566
public void SizeAppliedToStrings ( string source , string expected )
0 commit comments