// ------------------------------------------------------------------

// Real.cs: Represents OCL testing for the Real STL type

// ------------------------------------------------------------------

// Project: C# and OCL Compiler

// Module:  Testing

// Author:  Dave Arnold

// Version: 1.0

// ------------------------------------------------------------------

 

// ------------------------------------------------------------------

// Imports

// ------------------------------------------------------------------

using System;

using System.Collections;

// ------------------------------------------------------------------

 

// ------------------------------------------------------------------

// DaveArnold.OCLTesting Namespace

// ------------------------------------------------------------------

namespace DaveArnold.OCLTesting

{

       // A Class to test the Real expressions

       class RealTests

       {

              OCL

              [

                     "context RealTests::_r1 : Boolean"

                     "init: 2.2 = 2.2"

              ]

              private bool _r1;

             

              OCL

              [

                     "context RealTests::_r2 : Boolean"

                     "init: 2.2 = 2.3"

              ]

              private bool _r2;

             

              OCL

              [

                     "context RealTests::_r3 : Boolean"

                     "init: 2.2 <> 2.2"

              ]

              private bool _r3;

             

              OCL

              [

                     "context RealTests::_r4 : Boolean"

                     "init: 2.2 <> 2.3"

              ]

              private bool _r4;

             

              OCL

              [

                     "context RealTests::_r1a : Boolean"

                     "init: 2.2.=(2.2)"

              ]

              private bool _r1a;

             

              OCL

              [

                     "context RealTests::_r2a : Boolean"

                     "init: 2.2.=(2.3)"

              ]

              private bool _r2a;

             

              OCL

              [

                     "context RealTests::_r3a : Boolean"

                     "init: 2.2.<>(2.2)"

              ]

              private bool _r3a;

             

              OCL

              [

                     "context RealTests::_r4a : Boolean"

                     "init: 2.2.<>(2.3)"

              ]

              private bool _r4a;        

             

              OCL

              [

                     "context RealTests::_r5 : Real"

                     "init: 2.2 + 2.2"

              ]

              private double _r5;

             

              OCL

              [

                     "context RealTests::_r6 : Real"

                     "init: 2.2 + (2.2 * 2)"

              ]

              private double _r6;

             

              OCL

              [

                     "context RealTests::_r7 : Real"

                     "init: 2.2 + 2.2 + 2"

              ]

              private double _r7;

             

              OCL

              [

                     "context RealTests::_r8 : Real"

                     "init: (2.2 + 2.2) / 2"

              ]

              private double _r8;

             

              OCL

              [

                     "context RealTests::_r5a : Real"

                     "init: 2.2.+(2.2)"

              ]

              private double _r5a;

             

              OCL

              [

                     "context RealTests::_r6a : Real"

                     "init: 2.2.+(2.2 * 2)"

              ]

              private double _r6a;

             

              OCL

              [

                     "context RealTests::_r7a : Real"

                     "init: 2.2.+(2.2.+(2))"

              ]

              private double _r7a;

             

              OCL

              [

                     "context RealTests::_r8a : Real"

                     "init: (2.2.+(2.2)) / 2"

              ]

              private double _r8a;

             

              OCL

              [

                     "context RealTests::_r9 : Real"

                     "init: 2.2 - 2.2"

              ]

              private double _r9;

             

              OCL

              [

                     "context RealTests::_r10 : Real"

                     "init: 2.2 - (2.2 * 2)"

              ]

              private double _r10;

             

              OCL

              [

                     "context RealTests::_r11 : Real"

                     "init: 2.2 - 2.2 - 2"

              ]

              private double _r11;

             

              OCL

              [

                     "context RealTests::_r12 : Real"

                     "init: (4.2 - 2.2) / 2"

              ]

              private double _r12;

             

              OCL

              [

                     "context RealTests::_r9a : Real"

                     "init: 2.2.-(2.2)"

              ]

              private double _r9a;

             

              OCL

              [

                     "context RealTests::_r10a : Real"

                     "init: 2.2.-(2.2 * 2)"

              ]

              private double _r10a;

             

              OCL

              [

                     "context RealTests::_r11a : Real"

                     "init: 2.2.-(2.2.-(2))"

              ]

              private double _r11a;

             

              OCL

              [

                     "context RealTests::_r12a : Real"

                     "init: (4.2.-(2.2)) / 2"

              ]

              private double _r12a;            

              OCL

              [

                     "context RealTests::_r13 : Real"

                     "init: -4.3"

              ]

              private double _r13;

             

              OCL

              [

                     "context RealTests::_r14 : Real"

                     "init: - -4.3"

              ]

              private double _r14;

             

              OCL

              [

                     "context RealTests::_r13a : Real"

                     "init: 4.3.-()"

              ]

              private double _r13a;

             

              OCL

              [

                     "context RealTests::_r14a : Real"

                     "init: 4.3.-().-()"

              ]

              private double _r14a;

             

              OCL

              [

                     "context RealTests::_r15 : Real"

                     "init: 4.3.abs()"

              ]

              private double _r15;

             

              OCL

              [

                     "context RealTests::_r16 : Real"

                     "init: (-4.3).abs()"

              ]

              private double _r16;

             

             

              OCL

              [

                     "context RealTests::_r17 : Integer"

                     "init: 4.9999999.floor()"

              ]

              private int _r17;

             

              OCL

              [

                     "context RealTests::_r18 : Integer"

                     "init: (-4.3).floor()"

              ]

              private int _r18;

             

              OCL

              [

                     "context RealTests::_r19 : Integer"

                     "init: 4.9999999.round()"

              ]

              private int _r19;

             

              OCL

              [

                     "context RealTests::_r20 : Integer"

                     "init: (-4.3).round()"

              ]

              private int _r20;

             

                          

              OCL

              [

                     "context RealTests::_r21 : Real"

                     "init: 4.9999999.max(4.99999999)"

              ]

              private double _r21;

             

              OCL

              [

                     "context RealTests::_r22 : Real"

                     "init: 54.2.max(54.2)"

              ]

              private double _r22;

              OCL

              [

                     "context RealTests::_r23 : Real"

                     "init: 4.9999999.min(4.99999999)"

              ]

              private double _r23;

             

              OCL

              [

                     "context RealTests::_r24 : Real"

                     "init: 54.2.min(54.2)"

              ]

              private double _r24;

 

 

              OCL

              [

                     "context RealTests::_r25 : Boolean"

                     "init: 54.2 > 54.3"

              ]

              private bool _r25;

             

              OCL

              [

                     "context RealTests::_r26 : Boolean"

                     "init: 54.2 < 54.3"

              ]

              private bool _r26;

             

              OCL

              [

                     "context RealTests::_r27 : Boolean"

                     "init: 54.2 > 54.2"

              ]

              private bool _r27;

             

              OCL

              [

                     "context RealTests::_r28 : Boolean"

                     "init: 54.2 < 54.2"

              ]

              private bool _r28;

             

              OCL

              [

                     "context RealTests::_r29 : Boolean"

                     "init: 54.2 >= 54.2"

              ]

              private bool _r29;

             

              OCL

              [

                     "context RealTests::_r30 : Boolean"

                     "init: 54.2 <= 54.2"

              ]

              private bool _r30;

             

                     OCL

              [

                     "context RealTests::_r25a : Boolean"

                     "init: 54.2.>(54.3)"

              ]

              private bool _r25a;

             

              OCL

              [

                     "context RealTests::_r26a : Boolean"

                     "init: 54.2.<(54.3)"

              ]

              private bool _r26a;

             

              OCL

              [

                     "context RealTests::_r27a : Boolean"

                     "init: 54.2.>(54.2)"

              ]

              private bool _r27a;

             

              OCL

              [

                     "context RealTests::_r28a : Boolean"

                     "init: 54.2.<(54.2)"

              ]

              private bool _r28a;

             

              OCL

              [

                     "context RealTests::_r29a : Boolean"

                     "init: 54.2.>=(54.2)"

              ]

              private bool _r29a;

             

              OCL

              [

                     "context RealTests::_r30a : Boolean"

                     "init: 54.2.<=(54.2)"

              ]

              private bool _r30a;

             

             

              public void RunTests()

              {

                     Console.WriteLine("----------------- REAL TESTS ------------------");

                     Console.WriteLine("R1 (2.2 = 2.2): {0}", _r1);

                     Console.WriteLine("R2 (2.2 = 2.3): {0}", _r2);

                     Console.WriteLine("R3 (2.2 <> 2.2): {0}", _r3);

                     Console.WriteLine("R4 (2.2 <> 2.3): {0}", _r4);

                     Console.WriteLine("R1A (2.2.=(2.2)): {0}", _r1a);

                     Console.WriteLine("R2A (2.2.=(2.3)): {0}", _r2a);

                     Console.WriteLine("R3A (2.2.<>(2.2)): {0}", _r3a);

                     Console.WriteLine("R4A (2.2.<>(2.3)): {0}", _r4a);

                     Console.WriteLine("R5 (2.2 + 2.2): {0}", _r5);

                     Console.WriteLine("R6 (2.2 + (2.2 * 2)): {0}", _r6);

                     Console.WriteLine("R7 (2.2 + 2.2 + 2): {0}", _r7);

                     Console.WriteLine("R8 ((2.2 + 2.2) / 2): {0}", _r8);

                     Console.WriteLine("R5A (2.2.+(2.2)): {0}", _r5a);

                     Console.WriteLine("R6A (2.2.+(2.2 * 2)): {0}", _r6a);

                     Console.WriteLine("R7A (2.2.+(2.2.+(2))): {0}", _r7a);

                     Console.WriteLine("R8A ((2.2.+(2.2)) / 2): {0}", _r8a);

                     Console.WriteLine("R9 (2.2 - 2.2): {0}", _r9);

                     Console.WriteLine("R10 (2.2 - (2.2 * 2)): {0}", _r10);

                     Console.WriteLine("R11 (2.2 - 2.2 - 2): {0}", _r11);

                     Console.WriteLine("R12 ((4.2 - 2.2) / 2): {0}", _r12);

                     Console.WriteLine("R9A (2.2.-(2.2)): {0}", _r9a);

                     Console.WriteLine("R10A (2.2.-(2.2 * 2)): {0}", _r10a);

                     Console.WriteLine("R11A (2.2.-(2.2.-(2))): {0}", _r11a);

                     Console.WriteLine("R12A ((4.2.-(2.2)) / 2): {0}", _r12a);

                     Console.WriteLine("R13 (-4.3): {0}", _r13);

                     Console.WriteLine("R14 (- -4.3): {0}", _r14);

                     Console.WriteLine("R13A (4.3.-()): {0}", _r13a);

                     Console.WriteLine("R14A (4.3.-().-()): {0}", _r14a);

                     Console.WriteLine("R15 (4.3.abs()): {0}", _r15);

                     Console.WriteLine("R16 ((-4.3).abs()): {0}", _r16);

                     Console.WriteLine("R17 (4.9999999.floor()): {0}", _r17);

                     Console.WriteLine("R18 ((-4.3).floor()): {0}", _r18);

                     Console.WriteLine("R19 (4.9999999.round()): {0}", _r19);

                     Console.WriteLine("R20 ((-4.3).round()): {0}", _r20);

                     Console.WriteLine("R21 (4.9999999.max(4.99999999)): {0}", _r21);

                     Console.WriteLine("R22 (54.2.max(54.2)): {0}", _r22);

                     Console.WriteLine("R23 (4.9999999.min(4.99999999)): {0}", _r23);

                     Console.WriteLine("R24 (54.2.min(54.2)): {0}", _r24);

                     Console.WriteLine("R25 (54.2 < 54.3): {0}", _r25);

                     Console.WriteLine("R26 (54.2 > 54.3): {0}", _r26);

                     Console.WriteLine("R27 (54.2 < 54.2): {0}", _r27);

                     Console.WriteLine("R28 (54.2 > 54.2): {0}", _r28);

                     Console.WriteLine("R29 (54.2 <= 54.2): {0}", _r29);

                     Console.WriteLine("R30 (54.2 >= 54.2): {0}", _r30);

                     Console.WriteLine("R25A (54.2.<(54.3)): {0}", _r25a);

                     Console.WriteLine("R26A (54.2.>(54.3)): {0}", _r26a);

                     Console.WriteLine("R27A (54.2.<(54.2)): {0}", _r27a);

                     Console.WriteLine("R28A (54.2.>(54.2)): {0}", _r28a);

                     Console.WriteLine("R29A (54.2.<=(54.2)): {0}", _r29a);

                     Console.WriteLine("R30A (54.2.>=(54.2)): {0}", _r30a);

                     Console.WriteLine("------------- REAL TESTS COMPLETE -------------");

              }

       }

}

 

// ------------------------------------------------------------------

// EOF