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

// Integer.cs: Represents OCL testing for the Integer 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 Integer expressions

       class IntegerTests

       {

              OCL

              [

                     "context IntegerTests::_i1 : Boolean"

                     "init: 2 = 2"

              ]

              private bool _i1;

             

              OCL

              [

                     "context IntegerTests::_i2 : Boolean"

                     "init: 2 = 3"

              ]

              private bool _i2;

             

              OCL

              [

                     "context IntegerTests::_i3 : Boolean"

                     "init: 2 <> 2"

              ]

              private bool _i3;

             

              OCL

              [

                     "context IntegerTests::_i4 : Boolean"

                     "init: 2 <> 2"

              ]

              private bool _i4;

             

              OCL

              [

                     "context IntegerTests::_i1a : Boolean"

                     "init: 2.=(2)"

              ]

              private bool _i1a;

             

              OCL

              [

                     "context IntegerTests::_i2a : Boolean"

                     "init: 2.=(3)"

              ]

              private bool _i2a;

             

              OCL

              [

                     "context IntegerTests::_i3a : Boolean"

                     "init: 2.<>(2)"

              ]

              private bool _i3a;

             

              OCL

              [

                     "context IntegerTests::_i4a : Boolean"

                     "init: 2.<>(3)"

              ]

              private bool _i4a;        

             

              OCL

              [

                     "context IntegerTests::_i5 : Integer"

                     "init: 2 + 2"

              ]

              private int _i5;

             

              OCL

              [

                     "context IntegerTests::_i6 : Integer"

                     "init: 2 + (2 * 4)"

              ]

              private int _i6;

             

              OCL

              [

                     "context IntegerTests::_i7 : Integer"

                     "init: 2 + 2 + 4"

              ]

              private int _i7;

             

              OCL

              [

                     "context IntegerTests::_i8 : Real"

                     "init: (2 + 2) / 2"

              ]

              private double _i8;

             

              OCL

              [

                     "context IntegerTests::_i5a : Integer"

                     "init: 2.+(2)"

              ]

              private int _i5a;

             

              OCL

              [

                     "context IntegerTests::_i6a : Integer"

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

              ]

              private int _i6a;

             

              OCL

              [

                     "context IntegerTests::_i7a : Integer"

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

              ]

              private int _i7a;

             

              OCL

              [

                     "context IntegerTests::_i8a : Real"

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

              ]

              private double _i8a;

             

              OCL

              [

                     "context IntegerTests::_i9 : Integer"

                     "init: 2 - 2"

              ]

              private int _i9;

             

              OCL

              [

                     "context IntegerTests::_i10 : Integer"

                     "init: 2 - (2 * 4)"

              ]

              private int _i10;

             

              OCL

              [

                     "context IntegerTests::_i11 : Integer"

                     "init: 2 - 2 - 4"

              ]

              private int _i11;

             

              OCL

              [

                     "context IntegerTests::_i12 : Real"

                     "init: (4 - 2) / 2"

              ]

              private double _i12;

             

              OCL

              [

                     "context IntegerTests::_i9a : Integer"

                     "init: 2.-(2)"

              ]

              private int _i9a;

             

              OCL

              [

                     "context IntegerTests::_i10a : Integer"

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

              ]

              private int _i10a;

             

              OCL

              [

                     "context IntegerTests::_i11a : Integer"

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

              ]

              private int _i11a;

             

              OCL

              [

                     "context IntegerTests::_i12a : Real"

                     "init: (4.-(2)) / 2"

              ]

              private double _i12a;            

              OCL

              [

                     "context IntegerTests::_i13 : Integer"

                     "init: -4"

              ]

              private int _i13;

             

              OCL

              [

                     "context IntegerTests::_i14 : Integer"

                     "init: - -4"

              ]

              private int _i14;

             

              OCL

              [

                     "context IntegerTests::_i13a : Integer"

                     "init: 4.-()"

              ]

              private int _i13a;

             

              OCL

              [

                     "context IntegerTests::_i14a : Integer"

                     "init: 4.-().-()"

              ]

              private int _i14a;

             

              OCL

              [

                     "context IntegerTests::_i15 : Integer"

                     "init: 4.abs()"

              ]

              private int _i15;

             

              OCL

              [

                     "context IntegerTests::_i16 : Integer"

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

              ]

              private int _i16;

             

             

              OCL

              [

                     "context IntegerTests::_i17 : Integer"

                     "init: 4.floor()"

              ]

              private int _i17;

             

              OCL

              [

                     "context IntegerTests::_i18 : Integer"

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

              ]

              private int _i18;

             

              OCL

              [

                     "context IntegerTests::_i19 : Integer"

                     "init: 4.round()"

              ]

              private int _i19;

             

              OCL

              [

                     "context IntegerTests::_i20 : Integer"

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

              ]

              private int _i20;

             

                          

              OCL

              [

                     "context IntegerTests::_i21 : Integer"

                     "init: 4.max(3)"

              ]

              private int _i21;

             

              OCL

              [

                     "context IntegerTests::_i22 : Integer"

                     "init: 54.max(54)"

              ]

              private int _i22;

              OCL

              [

                     "context IntegerTests::_i23 : Integer"

                     "init: 4.min(3)"

              ]

              private int _i23;

             

              OCL

              [

                     "context IntegerTests::_i24 : Integer"

                     "init: 54.min(54)"

              ]

              private int _i24;

 

 

              OCL

              [

                     "context IntegerTests::_i25 : Boolean"

                     "init: 54 > 53"

              ]

              private bool _i25;

             

              OCL

              [

                     "context IntegerTests::_i26 : Boolean"

                     "init: 54 < 53"

              ]

              private bool _i26;

             

              OCL

              [

                     "context IntegerTests::_i27 : Boolean"

                     "init: 54 > 54"

              ]

              private bool _i27;

             

              OCL

              [

                     "context IntegerTests::_i28 : Boolean"

                     "init: 54 < 54"

              ]

              private bool _i28;

             

              OCL

              [

                     "context IntegerTests::_i29 : Boolean"

                     "init: 54 >= 54"

              ]

              private bool _i29;

             

              OCL

              [

                     "context IntegerTests::_i30 : Boolean"

                     "init: 54 <= 54"

              ]

              private bool _i30;

             

                     OCL

              [

                     "context IntegerTests::_i25a : Boolean"

                     "init: 54.>(53)"

              ]

              private bool _i25a;

             

              OCL

              [

                     "context IntegerTests::_i26a : Boolean"

                     "init: 54.<(53)"

              ]

              private bool _i26a;

             

              OCL

              [

                     "context IntegerTests::_i27a : Boolean"

                     "init: 54.>(54)"

              ]

              private bool _i27a;

             

              OCL

              [

                     "context IntegerTests::_i28a : Boolean"

                     "init: 54.<(54)"

              ]

              private bool _i28a;

             

              OCL

              [

                     "context IntegerTests::_i29a : Boolean"

                     "init: 54.>=(54)"

              ]

              private bool _i29a;

             

              OCL

              [

                     "context IntegerTests::_i30a : Boolean"

                     "init: 54.<=(54)"

              ]

              private bool _i30a;

             

              OCL

              [

                     "context IntegerTests::_i31 : Integer"

                     "init: 34 div 2"

              ]

              private int _i31;

             

              OCL

              [

                     "context IntegerTests::_i32 : Integer"

                     "init: 40 div (2 + 2)"

              ]

              private int _i32;

             

              OCL

              [

                     "context IntegerTests::_i31a : Integer"

                     "init: 34.div(2)"

              ]

              private int _i31a;

             

              OCL

              [

                     "context IntegerTests::_i32a : Integer"

                     "init: 40.div(2 + 2)"

              ]

              private int _i32a;

             

              OCL

              [

                     "context IntegerTests::_i33 : Integer"

                     "init: 37 mod 2"

              ]

              private int _i33;

             

              OCL

              [

                     "context IntegerTests::_i34 : Integer"

                     "init: 42 mod (2 + 2)"

              ]

              private int _i34;

             

              OCL

              [

                     "context IntegerTests::_i33a : Integer"

                     "init: 37.mod(2)"

              ]

              private int _i33a;

             

              OCL

              [

                     "context IntegerTests::_i34a : Integer"

                     "init: 42.mod(2 + 2)"

              ]

              private int _i34a;

             

              public void RunTests()

              {

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

                     Console.WriteLine("I1 (2 = 2): {0}", _i1);

                     Console.WriteLine("I2 (2 = 3): {0}", _i2);

                     Console.WriteLine("I3 (2 <> 2): {0}", _i3);

                     Console.WriteLine("I4 (2 <> 3): {0}", _i4);

                     Console.WriteLine("I1A (2.=(2)): {0}", _i1a);

                     Console.WriteLine("I2A (2.=(3)): {0}", _i2a);

                     Console.WriteLine("I3A (2.<>(2)): {0}", _i3a);

                     Console.WriteLine("I4A (2.<>(3)): {0}", _i4a);

                     Console.WriteLine("I5 (2 + 2): {0}", _i5);

                     Console.WriteLine("I6 (2 + (2 * 4)): {0}", _i6);

                     Console.WriteLine("I7 (2 + 2 + 4): {0}", _i7);

                     Console.WriteLine("I8 ((2 + 2) / 2): {0}", _i8);

                     Console.WriteLine("I5A (2.+(2)): {0}", _i5a);

                     Console.WriteLine("I6A (2.+(2 * 4)): {0}", _i6a);

                     Console.WriteLine("I7A (2.+(2.+(4))): {0}", _i7a);

                     Console.WriteLine("I8A ((2.+(2)) / 2): {0}", _i8a);

                     Console.WriteLine("I9 (2 - 2): {0}", _i9);

                     Console.WriteLine("I10 (2 - (2 * 4)): {0}", _i10);

                     Console.WriteLine("I11 (2 - 2 - 4): {0}", _i11);

                     Console.WriteLine("I12 ((4 - 2) / 2): {0}", _i12);

                     Console.WriteLine("I9A (2.-(2)): {0}", _i9a);

                     Console.WriteLine("I10A (2.-(2 * 4)): {0}", _i10a);

                     Console.WriteLine("I11A (2.-(2.-(4))): {0}", _i11a);

                     Console.WriteLine("I12A ((4.-(2)) / 2): {0}", _i12a);

                     Console.WriteLine("I13 (-4): {0}", _i13);

                     Console.WriteLine("I14 (- -4): {0}", _i14);

                     Console.WriteLine("I13A (4.-()): {0}", _i13a);

                     Console.WriteLine("I14A (4.-().-()): {0}", _i14a);

                     Console.WriteLine("I15 (4.abs()): {0}", _i15);

                     Console.WriteLine("I16 ((-4).abs()): {0}", _i16);

                     Console.WriteLine("I17 (4.floor()): {0}", _i17);

                     Console.WriteLine("I18 ((-4).floor()): {0}", _i18);

                     Console.WriteLine("I19 (4.round()): {0}", _i19);

                     Console.WriteLine("I20 ((-4).round()): {0}", _i20);

                     Console.WriteLine("I21 (4.max(3)): {0}", _i21);

                     Console.WriteLine("I22 (54.max(54)): {0}", _i22);

                     Console.WriteLine("I23 (4.min(3)): {0}", _i23);

                     Console.WriteLine("I24 (54.min(54)): {0}", _i24);

                     Console.WriteLine("I25 (54 < 53): {0}", _i25);

                     Console.WriteLine("I26 (54 > 53): {0}", _i26);

                     Console.WriteLine("I27 (54 < 54): {0}", _i27);

                     Console.WriteLine("I28 (54 > 54): {0}", _i28);

                     Console.WriteLine("I29 (54 <= 54): {0}", _i29);

                     Console.WriteLine("I30 (54 >= 54): {0}", _i30);

                     Console.WriteLine("I25A (54.<(53)): {0}", _i25a);

                     Console.WriteLine("I26A (54.>(53)): {0}", _i26a);

                     Console.WriteLine("I27A (54.<(54)): {0}", _i27a);

                     Console.WriteLine("I28A (54.>(54)): {0}", _i28a);

                     Console.WriteLine("I29A (54.<=(54)): {0}", _i29a);

                     Console.WriteLine("I30A (54.>=(54)): {0}", _i30a);

                     Console.WriteLine("I31 (34 div 2): {0}", _i31);

                     Console.WriteLine("I32 (40 div (2 + 2)): {0}", _i32);

                     Console.WriteLine("I31A (34.div(2)): {0}", _i31a);

                     Console.WriteLine("I32A (40.div(2 + 2)): {0}", _i32a);

                     Console.WriteLine("I33 (37 mod 2): {0}", _i33);

                     Console.WriteLine("I34 (42 mod (2 + 2)): {0}", _i34);

                     Console.WriteLine("I33A (37.mod(2)): {0}", _i33a);

                     Console.WriteLine("I34A (42.mod(2 + 2)): {0}", _i34a);

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

              }

       }

}

 

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

// EOF