edu.vub.at.objects.natives.grammar
Class TestParameterBinding

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byedu.vub.at.AmbientTalkTest
              extended byedu.vub.at.objects.natives.grammar.TestParameterBinding
All Implemented Interfaces:
junit.framework.Test

public class TestParameterBinding
extends AmbientTalkTest

Unit test for parameter binding during e.g. function call.

Author:
tvcutsem

Nested Class Summary
 
Nested classes inherited from class edu.vub.at.AmbientTalkTest
AmbientTalkTest.Actorscript
 
Field Summary
private  AGSymbol at_a
           
private  AGSymbol at_b
           
private  AGSymbol at_rest
           
private  AGSymbol at_x
           
private  AGSymbol at_y
           
private  NATContext bindCtx_
           
private  NATObject bindScope_
           
private  NATMethod fun1
           
private  NATMethod fun2
           
private  NATMethod fun3
           
private  NATMethod fun4
           
private  NATMethod fun5
           
private  NATMethod fun6
           
private  NATMethod fun7
           
 
Fields inherited from class edu.vub.at.AmbientTalkTest
ctx_
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
TestParameterBinding()
           
 
Method Summary
private  void ensureBound(ATSymbol var, ATObject value)
           
private  void ensureBoundToTable(ATSymbol var, ATObject[] expected)
           
private  NATMethod makeTestMethod(java.lang.String nam, NATTable pars)
          Given a name and parameters, returns a method def name(parameters) { nil }
 void setUp()
           
 void testIllegalMandatoryAfterOptional()
          Tests whether mandatory arguments specified after optional arguments results in a proper XIllegalParameter exception.
 void testIllegalMandatoryAfterRest()
          Tests whether mandatory arguments specified after the rest parameter results in a proper XIllegalParameter exception.
 void testIllegalOptionalAfterRest()
          Tests whether optional arguments specified after the rest parameter results in a proper XIllegalParameter exception.
 void testMandatory()
          Tests parameter binding for methods with mandatory arguments only.
 void testMandatoryAndDefaultOptional()
          Tests parameter binding for methods with mandatory arguments and an optional argument that is not given.
 void testMandatoryAndOptional()
          Tests parameter binding for methods with mandatory arguments and optional arguments.
 void testMandatoryAndTooManyOptional()
          Tests whether parameter binding fails if given too many optional arguments.
 void testMandNoOptAndNoRest()
          Tests application with mandatory arguments.
 void testMandOptAndNoRest()
          Tests application with mandatory and optional arguments.
 void testMandOptAndRest()
          Tests application with both mandatory, optional and rest arguments
 void testMultiAssignmentWithOptionalAndRestParameters()
          Tests whether optional and rest parameters also work using multiple-definition
 void testOneMandatoryAndNoRestArgs()
          Tests application with one mandatory argument and zero rest arguments.
 void testOneMandatoryAndTwoRestArgs()
          Tests application with one mandatory argument and two rest arguments.
 void testOneRestArg()
          Tests only rest arguments, with one given.
 void testOnlyOptArgsWithNoneFilledIn()
          Tests application with only optional arguments, none of which are given at call time.
 void testOnlyOptArgsWithOneFilledIn()
          Tests application with only optional arguments, only one of which is given at call time.
 void testOnlyOptionalArguments()
          Tests application with only optional arguments, all of which are given at call time.
 void testTooFewMandatory()
          Tests for too few mandatory arguments
 void testTooManyMandatory()
          Tests for too many mandatory arguments
 void testZeroArity()
          Tests parameter binding for 0-arity methods
 void testZeroRestArgs()
          Tests only rest arguments, with none given.
 
Methods inherited from class edu.vub.at.AmbientTalkTest
actorTest, evalActor, evalAndCompareTo, evalAndCompareTo, evalAndReturn, evalAndTestException, evalInActor, evalSnippet, printedEquals
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bindCtx_

private NATContext bindCtx_

bindScope_

private NATObject bindScope_

at_a

private final AGSymbol at_a

at_b

private final AGSymbol at_b

at_rest

private final AGSymbol at_rest

at_x

private final AGSymbol at_x

at_y

private final AGSymbol at_y

fun1

private NATMethod fun1

fun2

private NATMethod fun2

fun3

private NATMethod fun3

fun4

private NATMethod fun4

fun5

private NATMethod fun5

fun6

private NATMethod fun6

fun7

private NATMethod fun7
Constructor Detail

TestParameterBinding

public TestParameterBinding()
Method Detail

ensureBound

private void ensureBound(ATSymbol var,
                         ATObject value)
                  throws InterpreterException
Throws:
InterpreterException

ensureBoundToTable

private void ensureBoundToTable(ATSymbol var,
                                ATObject[] expected)
                         throws InterpreterException
Throws:
InterpreterException

makeTestMethod

private NATMethod makeTestMethod(java.lang.String nam,
                                 NATTable pars)
Given a name and parameters, returns a method def name(parameters) { nil }


setUp

public void setUp()
           throws InterpreterException
Throws:
InterpreterException

testZeroArity

public void testZeroArity()
                   throws InterpreterException
Tests parameter binding for 0-arity methods

Throws:
InterpreterException

testMandatory

public void testMandatory()
                   throws InterpreterException
Tests parameter binding for methods with mandatory arguments only.

Throws:
InterpreterException

testTooFewMandatory

public void testTooFewMandatory()
                         throws InterpreterException
Tests for too few mandatory arguments

Throws:
InterpreterException

testTooManyMandatory

public void testTooManyMandatory()
                          throws InterpreterException
Tests for too many mandatory arguments

Throws:
InterpreterException

testMandatoryAndOptional

public void testMandatoryAndOptional()
                              throws InterpreterException
Tests parameter binding for methods with mandatory arguments and optional arguments.

Throws:
InterpreterException

testMandatoryAndDefaultOptional

public void testMandatoryAndDefaultOptional()
                                     throws InterpreterException
Tests parameter binding for methods with mandatory arguments and an optional argument that is not given.

Throws:
InterpreterException

testMandatoryAndTooManyOptional

public void testMandatoryAndTooManyOptional()
                                     throws InterpreterException
Tests whether parameter binding fails if given too many optional arguments.

Throws:
InterpreterException

testMandOptAndRest

public void testMandOptAndRest()
                        throws InterpreterException
Tests application with both mandatory, optional and rest arguments

Throws:
InterpreterException

testMandOptAndNoRest

public void testMandOptAndNoRest()
                          throws InterpreterException
Tests application with mandatory and optional arguments. The rest arguments should be []

Throws:
InterpreterException

testMandNoOptAndNoRest

public void testMandNoOptAndNoRest()
                            throws InterpreterException
Tests application with mandatory arguments. The optional argument should be initialized to its default expression. Note that this default expression also tests for let*-like behaviour! The rest arguments should be []

Throws:
InterpreterException

testOnlyOptionalArguments

public void testOnlyOptionalArguments()
                               throws InterpreterException
Tests application with only optional arguments, all of which are given at call time.

Throws:
InterpreterException

testOnlyOptArgsWithOneFilledIn

public void testOnlyOptArgsWithOneFilledIn()
                                    throws InterpreterException
Tests application with only optional arguments, only one of which is given at call time.

Throws:
InterpreterException

testOnlyOptArgsWithNoneFilledIn

public void testOnlyOptArgsWithNoneFilledIn()
                                     throws InterpreterException
Tests application with only optional arguments, none of which are given at call time.

Throws:
InterpreterException

testOneMandatoryAndNoRestArgs

public void testOneMandatoryAndNoRestArgs()
                                   throws InterpreterException
Tests application with one mandatory argument and zero rest arguments.

Throws:
InterpreterException

testOneMandatoryAndTwoRestArgs

public void testOneMandatoryAndTwoRestArgs()
                                    throws InterpreterException
Tests application with one mandatory argument and two rest arguments.

Throws:
InterpreterException

testZeroRestArgs

public void testZeroRestArgs()
                      throws InterpreterException
Tests only rest arguments, with none given.

Throws:
InterpreterException

testOneRestArg

public void testOneRestArg()
                    throws InterpreterException
Tests only rest arguments, with one given.

Throws:
InterpreterException

testIllegalMandatoryAfterOptional

public void testIllegalMandatoryAfterOptional()
                                       throws InterpreterException
Tests whether mandatory arguments specified after optional arguments results in a proper XIllegalParameter exception.

Throws:
InterpreterException

testIllegalMandatoryAfterRest

public void testIllegalMandatoryAfterRest()
                                   throws InterpreterException
Tests whether mandatory arguments specified after the rest parameter results in a proper XIllegalParameter exception.

Throws:
InterpreterException

testIllegalOptionalAfterRest

public void testIllegalOptionalAfterRest()
                                  throws InterpreterException
Tests whether optional arguments specified after the rest parameter results in a proper XIllegalParameter exception.

Throws:
InterpreterException

testMultiAssignmentWithOptionalAndRestParameters

public void testMultiAssignmentWithOptionalAndRestParameters()
                                                      throws InterpreterException
Tests whether optional and rest parameters also work using multiple-definition

Throws:
InterpreterException