@@ -2597,25 +2597,29 @@ ExpressionEvaluator evaluatorForMethodArgs()
2597
2597
, "Persons.Sum(x=>x.Number)"
2598
2598
, null )
2599
2599
. Returns ( 23.22m )
2600
- . SetCategory ( "Bug resolution" ) ;
2600
+ . SetCategory ( "Bug resolution" )
2601
+ . SetCategory ( "#65" ) ;
2601
2602
2602
2603
yield return new TestCaseData ( new ExpressionEvaluator ( ) { Context = new { Persons } }
2603
2604
, "Persons.Average(x=>x.Number)"
2604
2605
, null )
2605
2606
. Returns ( 11.61m )
2606
- . SetCategory ( "Bug resolution" ) ;
2607
+ . SetCategory ( "Bug resolution" )
2608
+ . SetCategory ( "#65" ) ;
2607
2609
2608
2610
yield return new TestCaseData ( new ExpressionEvaluator ( ) { Context = new { Persons } }
2609
2611
, "Persons.Max(x=>x.Number)"
2610
2612
, null )
2611
2613
. Returns ( 12.11m )
2612
- . SetCategory ( "Bug resolution" ) ;
2614
+ . SetCategory ( "Bug resolution" )
2615
+ . SetCategory ( "#65" ) ;
2613
2616
2614
2617
yield return new TestCaseData ( new ExpressionEvaluator ( ) { Context = new { Persons } }
2615
2618
, "Persons.Min(x=>x.Number)"
2616
2619
, null )
2617
2620
. Returns ( 11.11m )
2618
- . SetCategory ( "Bug resolution" ) ;
2621
+ . SetCategory ( "Bug resolution" )
2622
+ . SetCategory ( "#65" ) ;
2619
2623
2620
2624
#endregion
2621
2625
@@ -2626,20 +2630,23 @@ ExpressionEvaluator evaluatorForMethodArgs()
2626
2630
, null )
2627
2631
. Returns ( Environment . GetFolderPath ( Environment . SpecialFolder . CommonApplicationData ) )
2628
2632
. SetCategory ( "Bug resolution" )
2633
+ . SetCategory ( "#95" )
2629
2634
. SetCategory ( "NestedType" ) ;
2630
2635
2631
2636
yield return new TestCaseData ( new ExpressionEvaluator ( )
2632
2637
, "Environment.GetFolderPath((Environment.SpecialFolder)5)"
2633
2638
, null )
2634
2639
. Returns ( Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) )
2635
2640
. SetCategory ( "Bug resolution" )
2641
+ . SetCategory ( "#95" )
2636
2642
. SetCategory ( "NestedType" ) ;
2637
2643
2638
2644
yield return new TestCaseData ( new ExpressionEvaluator ( )
2639
2645
, "new CodingSeb.ExpressionEvaluator.Tests.OtherNamespace.ClassInOtherNameSpace1.ANestedClass().Value1"
2640
2646
, null )
2641
2647
. Returns ( 45 )
2642
2648
. SetCategory ( "Bug resolution" )
2649
+ . SetCategory ( "#95" )
2643
2650
. SetCategory ( "NestedType" ) ;
2644
2651
2645
2652
#endregion
@@ -2651,97 +2658,103 @@ ExpressionEvaluator evaluatorForMethodArgs()
2651
2658
, null )
2652
2659
. Returns ( - 1 )
2653
2660
. SetCategory ( "Bug resolution" )
2661
+ . SetCategory ( "#95" )
2654
2662
. SetCategory ( "MethodNameAsDelegates" ) ;
2655
2663
2656
2664
yield return new TestCaseData ( new ExpressionEvaluator ( )
2657
2665
, "Array.ConvertAll<string,int>(\" 1,2,3,4,5,6,-1\" .Split(','), Int32.Parse).Min()"
2658
2666
, null )
2659
2667
. Returns ( - 1 )
2660
2668
. SetCategory ( "Bug resolution" )
2669
+ . SetCategory ( "#95" )
2661
2670
. SetCategory ( "MethodNameAsDelegates" ) ;
2662
2671
2663
2672
yield return new TestCaseData ( new ExpressionEvaluator ( )
2664
2673
, "Array.ConvertAll(\" 1,2,3,4,5,6,-1\" .Split(','), s => Int32.Parse(s)).Min()"
2665
2674
, null )
2666
2675
. Returns ( - 1 )
2667
2676
. SetCategory ( "Bug resolution" )
2677
+ . SetCategory ( "#95" )
2668
2678
. SetCategory ( "MethodNameAsDelegates" ) ;
2669
2679
2670
2680
yield return new TestCaseData ( new ExpressionEvaluator ( )
2671
2681
, "Array.ConvertAll<string, int>(\" 1,2,3,4,5,6,-1\" .Split(','), s => Int32.Parse(s)).Min()"
2672
2682
, null )
2673
2683
. Returns ( - 1 )
2674
2684
. SetCategory ( "Bug resolution" )
2685
+ . SetCategory ( "#95" )
2675
2686
. SetCategory ( "MethodNameAsDelegates" ) ;
2676
2687
2677
2688
yield return new TestCaseData ( new ExpressionEvaluator ( )
2678
2689
, "Array.ConvertAll(\" test for Upper\" .ToCharArray(), Char.IsUpper)"
2679
2690
, null )
2680
2691
. Returns ( Array . ConvertAll ( "test for Upper" . ToCharArray ( ) , Char . IsUpper ) )
2681
2692
. SetCategory ( "Bug resolution" )
2693
+ . SetCategory ( "#95" )
2682
2694
. SetCategory ( "MethodNameAsDelegates" ) ;
2683
2695
2684
- //yield return new TestCaseData(new ExpressionEvaluator()
2685
- // , "Array.ConvertAll(\"test for Upper\".ToCharArray(),u => u => Char.IsUpper(u) ? Char.ToLower(u) : Char.ToUpper(u))"
2686
- // , null)
2687
- // .Returns(Array.ConvertAll("test for Upper".ToCharArray(), u => Char.IsUpper(u) ? Char.ToLower(u) : Char.ToUpper(u)))
2688
- // .SetCategory("Bug resolution")
2689
- // .SetCategory("MethodNameAsDelegates");
2690
-
2691
2696
yield return new TestCaseData ( new ExpressionEvaluator ( )
2692
2697
, "(() => { var m = int.Parse; return m(\" 5\" ); })()"
2693
2698
, null )
2694
2699
. Returns ( 5 )
2695
2700
. SetCategory ( "Bug resolution" )
2701
+ . SetCategory ( "#95" )
2696
2702
. SetCategory ( "MethodNameAsDelegates" ) ;
2697
2703
2698
2704
yield return new TestCaseData ( new ExpressionEvaluator ( )
2699
2705
, "\" test for Upper\" .ToCharArray().First(Char.IsUpper)"
2700
2706
, null )
2701
2707
. Returns ( 'U' )
2702
2708
. SetCategory ( "Bug resolution" )
2709
+ . SetCategory ( "#95" )
2703
2710
. SetCategory ( "MethodNameAsDelegates" ) ;
2704
2711
2705
2712
yield return new TestCaseData ( new ExpressionEvaluator ( )
2706
2713
, "\" test for Upper\" .ToCharArray().First(Char.IsUpper)"
2707
2714
, null )
2708
2715
. Returns ( 'U' )
2709
2716
. SetCategory ( "Bug resolution" )
2717
+ . SetCategory ( "#95" )
2710
2718
. SetCategory ( "MethodNameAsDelegates" ) ;
2711
2719
2712
2720
yield return new TestCaseData ( new ExpressionEvaluator ( )
2713
2721
, "\" test for Upper\" .ToCharArray().First(c => Char.IsUpper(c))"
2714
2722
, null )
2715
2723
. Returns ( 'U' )
2716
2724
. SetCategory ( "Bug resolution" )
2725
+ . SetCategory ( "#95" )
2717
2726
. SetCategory ( "MethodNameAsDelegates" ) ;
2718
2727
2719
2728
yield return new TestCaseData ( new ExpressionEvaluator ( )
2720
2729
, "Array.Find(\" test for Upper\" .ToCharArray(), Char.IsUpper)"
2721
2730
, null )
2722
2731
. Returns ( 'U' )
2723
2732
. SetCategory ( "Bug resolution" )
2733
+ . SetCategory ( "#95" )
2724
2734
. SetCategory ( "MethodNameAsDelegates" ) ;
2725
2735
2726
2736
yield return new TestCaseData ( new ExpressionEvaluator ( )
2727
2737
, "Array.Find(\" test for Upper\" .ToCharArray(), c => Char.IsUpper(c))"
2728
2738
, null )
2729
2739
. Returns ( 'U' )
2730
2740
. SetCategory ( "Bug resolution" )
2741
+ . SetCategory ( "#95" )
2731
2742
. SetCategory ( "MethodNameAsDelegates" ) ;
2732
2743
2733
2744
yield return new TestCaseData ( new ExpressionEvaluator ( )
2734
2745
, "\" test for Upper\" .ToCharArray().Any(Char.IsUpper)"
2735
2746
, null )
2736
2747
. Returns ( true )
2737
2748
. SetCategory ( "Bug resolution" )
2749
+ . SetCategory ( "#95" )
2738
2750
. SetCategory ( "MethodNameAsDelegates" ) ;
2739
2751
2740
2752
yield return new TestCaseData ( new ExpressionEvaluator ( )
2741
2753
, "\" test for Upper\" .ToCharArray().ToList().First(Char.IsUpper)"
2742
2754
, null )
2743
2755
. Returns ( 'U' )
2744
2756
. SetCategory ( "Bug resolution" )
2757
+ . SetCategory ( "#95" )
2745
2758
. SetCategory ( "MethodNameAsDelegates" ) ;
2746
2759
2747
2760
#endregion
@@ -2752,48 +2765,56 @@ ExpressionEvaluator evaluatorForMethodArgs()
2752
2765
, "typeof(double[])"
2753
2766
, null )
2754
2767
. Returns ( typeof ( double [ ] ) )
2768
+ . SetCategory ( "#100" )
2755
2769
. SetCategory ( "Bug resolution" ) ;
2756
2770
2757
2771
yield return new TestCaseData ( new ExpressionEvaluator ( )
2758
2772
, "typeof(double[ ])"
2759
2773
, null )
2760
2774
. Returns ( typeof ( double [ ] ) )
2775
+ . SetCategory ( "#100" )
2761
2776
. SetCategory ( "Bug resolution" ) ;
2762
2777
2763
2778
yield return new TestCaseData ( new ExpressionEvaluator ( )
2764
2779
, "typeof(double[][])"
2765
2780
, null )
2766
2781
. Returns ( typeof ( double [ ] [ ] ) )
2782
+ . SetCategory ( "#100" )
2767
2783
. SetCategory ( "Bug resolution" ) ;
2768
2784
2769
2785
yield return new TestCaseData ( new ExpressionEvaluator ( )
2770
2786
, "typeof(double[,])"
2771
2787
, null )
2772
2788
. Returns ( typeof ( double [ , ] ) )
2789
+ . SetCategory ( "#100" )
2773
2790
. SetCategory ( "Bug resolution" ) ;
2774
2791
2775
2792
yield return new TestCaseData ( new ExpressionEvaluator ( )
2776
2793
, "typeof(int[])"
2777
2794
, null )
2778
2795
. Returns ( typeof ( int [ ] ) )
2796
+ . SetCategory ( "#100" )
2779
2797
. SetCategory ( "Bug resolution" ) ;
2780
2798
2781
2799
yield return new TestCaseData ( new ExpressionEvaluator ( )
2782
2800
, "typeof(Int32[])"
2783
2801
, null )
2784
2802
. Returns ( typeof ( Int32 [ ] ) )
2803
+ . SetCategory ( "#100" )
2785
2804
. SetCategory ( "Bug resolution" ) ;
2786
2805
2787
2806
yield return new TestCaseData ( new ExpressionEvaluator ( )
2788
2807
, "typeof(string[])"
2789
2808
, null )
2790
2809
. Returns ( typeof ( string [ ] ) )
2810
+ . SetCategory ( "#100" )
2791
2811
. SetCategory ( "Bug resolution" ) ;
2792
2812
2793
2813
yield return new TestCaseData ( new ExpressionEvaluator ( )
2794
2814
, "typeof(Regex[])"
2795
2815
, null )
2796
2816
. Returns ( typeof ( Regex [ ] ) )
2817
+ . SetCategory ( "#100" )
2797
2818
. SetCategory ( "Bug resolution" ) ;
2798
2819
2799
2820
yield return new TestCaseData ( new ExpressionEvaluator ( new ObjectContainer ( )
@@ -2803,6 +2824,41 @@ ExpressionEvaluator evaluatorForMethodArgs()
2803
2824
, "(double[])AnObjectProperty"
2804
2825
, null )
2805
2826
. Returns ( new double [ ] { 1.1 , 2.3 , 4.3 } )
2827
+ . SetCategory ( "#100" )
2828
+ . SetCategory ( "Bug resolution" ) ;
2829
+
2830
+ #endregion
2831
+
2832
+ #region for issue #110 OptionForceIntegerNumbersEvaluationsAsDoubleByDefault leads to exception when dividing
2833
+
2834
+ yield return new TestCaseData ( new ExpressionEvaluator ( )
2835
+ {
2836
+ OptionForceIntegerNumbersEvaluationsAsDoubleByDefault = true ,
2837
+ }
2838
+ , "3/Math.Round(Avg(1,2),MidpointRounding.AwayFromZero)"
2839
+ , null )
2840
+ . Returns ( 1.5d )
2841
+ . SetCategory ( "#110" )
2842
+ . SetCategory ( "Bug resolution" ) ;
2843
+
2844
+ yield return new TestCaseData ( new ExpressionEvaluator ( )
2845
+ {
2846
+ OptionForceIntegerNumbersEvaluationsAsDoubleByDefault = true ,
2847
+ }
2848
+ , "Math.Round(1.5,MidpointRounding.AwayFromZero)"
2849
+ , null )
2850
+ . Returns ( 2d )
2851
+ . SetCategory ( "#110" )
2852
+ . SetCategory ( "Bug resolution" ) ;
2853
+
2854
+ yield return new TestCaseData ( new ExpressionEvaluator ( )
2855
+ {
2856
+ OptionForceIntegerNumbersEvaluationsAsDoubleByDefault = true ,
2857
+ }
2858
+ , "Avg(1,2)"
2859
+ , null )
2860
+ . Returns ( 1.5d )
2861
+ . SetCategory ( "#110" )
2806
2862
. SetCategory ( "Bug resolution" ) ;
2807
2863
2808
2864
#endregion
0 commit comments