Beispiel #1
0
 public static void argit2b (__arglist)
   {
   ArgIterator args = new ArgIterator( __arglist );
   int hashcode = args.GetHashCode();
   TypedReference trTypRef = args.GetNextArg();
   int hashcodecompare= args.GetHashCode();
   if (! hashcode.Equals(hashcodecompare))
     {
     throw new Exception( "argit2b - 1, hashcode changed" );
     }
   }
Beispiel #2
0
    public static void argit2b(__arglist)
    {
        ArgIterator    args            = new ArgIterator(__arglist);
        int            hashcode        = args.GetHashCode();
        TypedReference trTypRef        = args.GetNextArg();
        int            hashcodecompare = args.GetHashCode();

        if (!hashcode.Equals(hashcodecompare))
        {
            throw new Exception("argit2b - 1, hashcode changed");
        }
    }
Beispiel #3
0
//Test 1
	// check whether GetHashCode returns the same value
	// check to see if we can use ArgIterators on any class
	// check ArgIterators on Arrays
	// test arg iterators with instance methods on normal classes
	public TestStruct argit1( Object[] objExpectedArr, __arglist )
	{
		ArgIterator args = new ArgIterator( __arglist );
		int hashcode = args.GetHashCode();
		
		int iCount = args.GetRemainingCount();
                Console.WriteLine( "Found  "+ iCount +" arguments. " );  
		Object[] objArr = new Object[iCount];

		for ( int i = 0; i < iCount; i++ ){
			objArr[i] = TypedReference.ToObject(args.GetNextArg());
                        Console.WriteLine( "Object  " + i + ": " + objArr[i] + " Expected: " + objExpectedArr[i] );  
			if ( objExpectedArr[i] == null ){
				if ( objArr[i] != null ){
					throw new Exception( "argit1 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
				}
			}
			
			else if ( ! objArr[i].Equals( objExpectedArr[i] ) ) {
				throw new Exception( "argit1 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
			}
		}		

		//repeating the code above __arglist should be valid in method scope
		ArgIterator args2 = new ArgIterator( __arglist );
		int iCount2 = args2.GetRemainingCount();
		Object[] objArr2 = new Object[iCount];

		for ( int i = 0; i < iCount2; i++ ){
			objArr2[i] = TypedReference.ToObject(args2.GetNextArg());
                        Console.WriteLine( "Object  " + i + ": " + objArr2[i] + " Expected: " + objExpectedArr[i] );
			if ( objExpectedArr[i] == null ){
				if ( objArr2[i] != null ){
					throw new Exception( "argit1 - 3, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
				}
			}
			
			else if ( ! objArr2[i].Equals( objExpectedArr[i] ) ) {
				throw new Exception( "argit1 - 4, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
			}
		}				
		int hashcodecompare= args.GetHashCode();
		if (! hashcode.Equals(hashcodecompare))
			{
				throw new Exception( "argit1 - 5, hashcode changed" );
			}
                TestStruct Bar = new TestStruct();
                Bar.foo1 = 1;
                Bar.foo2 = 2;
                return Bar;
	}
Beispiel #4
0
 public static void argit2 (__arglist)
   {
   ArgIterator args = new ArgIterator( __arglist );	
   int hashcode = args.GetHashCode();
   try{
   NormClass.argit2b( __arglist(   ) );
   }
   catch (InvalidOperationException) {}
   int hashcodecompare= args.GetHashCode();
   if (! hashcode.Equals(hashcodecompare))
     {
     throw new Exception( "argit2 - 1, hashcode changed" );
     }
   }
Beispiel #5
0
    public void argit1(Object[] objExpectedArr, __arglist)
    {
        ArgIterator args     = new ArgIterator(__arglist);
        int         hashcode = args.GetHashCode();
        int         iCount   = args.GetRemainingCount();

        Object[] objArr = new Object[iCount];
        for (int i = 0; i < iCount; i++)
        {
            objArr[i] = TypedReference.ToObject(args.GetNextArg());
            if (objExpectedArr[i] == null)
            {
                if (objArr[i] != null)
                {
                    throw new Exception("argit1 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]");
                }
            }
            else if (!objArr[i].Equals(objExpectedArr[i]))
            {
                throw new Exception("argit1 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]");
            }
        }
        ArgIterator args2   = new ArgIterator(__arglist);
        int         iCount2 = args2.GetRemainingCount();

        Object[] objArr2 = new Object[iCount];
        for (int i = 0; i < iCount2; i++)
        {
            objArr2[i] = TypedReference.ToObject(args2.GetNextArg());
            if (objExpectedArr[i] == null)
            {
                if (objArr2[i] != null)
                {
                    throw new Exception("argit1 - 3, __arglist[i] was null but it did not equal to objExpectedArr[i]");
                }
            }
            else if (!objArr2[i].Equals(objExpectedArr[i]))
            {
                throw new Exception("argit1 - 4, __arglist[i] was null but it did not equal to objExpectedArr[i]");
            }
        }
        int hashcodecompare = args.GetHashCode();

        if (!hashcode.Equals(hashcodecompare))
        {
            throw new Exception("argit1 - 5, hashcode changed");
        }
    }
Beispiel #6
0
    public static void argit2(__arglist)
    {
        ArgIterator args     = new ArgIterator(__arglist);
        int         hashcode = args.GetHashCode();

        try{
            NormClass.argit2b(__arglist(   ));
        }
        catch (InvalidOperationException) {}
        int hashcodecompare = args.GetHashCode();

        if (!hashcode.Equals(hashcodecompare))
        {
            throw new Exception("argit2 - 1, hashcode changed");
        }
    }
Beispiel #7
0
 public void argit1( Object[] objExpectedArr, __arglist )
   {
   ArgIterator args = new ArgIterator( __arglist );
   int hashcode = args.GetHashCode();
   int iCount = args.GetRemainingCount();
   Object[] objArr = new Object[iCount];
   for ( int i = 0; i < iCount; i++ ){
   objArr[i] = TypedReference.ToObject(args.GetNextArg());
   if ( objExpectedArr[i] == null ){
   if ( objArr[i] != null ){
   throw new Exception( "argit1 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }
   else if ( ! objArr[i].Equals( objExpectedArr[i] ) ) {
   throw new Exception( "argit1 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }		
   ArgIterator args2 = new ArgIterator( __arglist );
   int iCount2 = args2.GetRemainingCount();
   Object[] objArr2 = new Object[iCount];
   for ( int i = 0; i < iCount2; i++ ){
   objArr2[i] = TypedReference.ToObject(args2.GetNextArg());
   if ( objExpectedArr[i] == null ){
   if ( objArr2[i] != null ){
   throw new Exception( "argit1 - 3, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }
   else if ( ! objArr2[i].Equals( objExpectedArr[i] ) ) {
   throw new Exception( "argit1 - 4, __arglist[i] was null but it did not equal to objExpectedArr[i]" );
   }
   }				
   int hashcodecompare= args.GetHashCode();
   if (! hashcode.Equals(hashcodecompare))
     {
     throw new Exception( "argit1 - 5, hashcode changed" );
     }
   }
Beispiel #8
0
//Test 1
    // check whether GetHashCode returns the same value
    // check to see if we can use ArgIterators on any class
    // check ArgIterators on Arrays
    // test arg iterators with instance methods on normal classes
    public TestStruct argit1(Object[] objExpectedArr, __arglist)
    {
        ArgIterator args     = new ArgIterator(__arglist);
        int         hashcode = args.GetHashCode();

        int iCount = args.GetRemainingCount();

        Console.WriteLine("Found  " + iCount + " arguments. ");
        Object[] objArr = new Object[iCount];

        for (int i = 0; i < iCount; i++)
        {
            objArr[i] = TypedReference.ToObject(args.GetNextArg());
            Console.WriteLine("Object  " + i + ": " + objArr[i] + " Expected: " + objExpectedArr[i]);
            if (objExpectedArr[i] == null)
            {
                if (objArr[i] != null)
                {
                    throw new Exception("argit1 - 1, __arglist[i] was null but it did not equal to objExpectedArr[i]");
                }
            }

            else if (!objArr[i].Equals(objExpectedArr[i]))
            {
                throw new Exception("argit1 - 2, __arglist[i] was null but it did not equal to objExpectedArr[i]");
            }
        }

        //repeating the code above __arglist should be valid in method scope
        ArgIterator args2   = new ArgIterator(__arglist);
        int         iCount2 = args2.GetRemainingCount();

        Object[] objArr2 = new Object[iCount];

        for (int i = 0; i < iCount2; i++)
        {
            objArr2[i] = TypedReference.ToObject(args2.GetNextArg());
            Console.WriteLine("Object  " + i + ": " + objArr2[i] + " Expected: " + objExpectedArr[i]);
            if (objExpectedArr[i] == null)
            {
                if (objArr2[i] != null)
                {
                    throw new Exception("argit1 - 3, __arglist[i] was null but it did not equal to objExpectedArr[i]");
                }
            }

            else if (!objArr2[i].Equals(objExpectedArr[i]))
            {
                throw new Exception("argit1 - 4, __arglist[i] was null but it did not equal to objExpectedArr[i]");
            }
        }
        int hashcodecompare = args.GetHashCode();

        if (!hashcode.Equals(hashcodecompare))
        {
            throw new Exception("argit1 - 5, hashcode changed");
        }
        TestStruct Bar = new TestStruct();

        Bar.foo1 = 1;
        Bar.foo2 = 2;
        return(Bar);
    }