CountNodes: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
KKeine Bearbeitungszusammenfassung
Zeile 18: Zeile 18:
==== Benutzung mit Variablen ====
==== Benutzung mit Variablen ====
  countNodes([pos=1])
  countNodes([pos=1])
  countNodes([var=a])
  countNodes([var=a])
====JUnit Tests====
<span class="mw-customtoggle-myDivision">[Anzeigen]</span>
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision">
@Test
public void testCountNodes1() {
assertEquals(4, Evaluator.getNumberResult("countNodes(2+2)", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodes2() {
assertEquals(7, Evaluator.getNumberResult("countNodes(3*(2+2))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodes3() {
assertNotEquals(1, Evaluator.getNumberResult("countNodes(2+2)", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodesWithInput1() {
assertEquals(1, Evaluator.getNumberResult("countNodes([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodesWithInput2() {
assertEquals(7, Evaluator.getNumberResult("countNodes(3*([pos=1]+2))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodesWithVariables1() {
assertEquals(1, Evaluator.getNumberResult("countNodes([var=a])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodesWithVariables2() {
assertEquals(7, Evaluator.getNumberResult("countNodes(3*([var=a]+2))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testCountNodesWithExpressions() {
assertEquals(6, Evaluator.getNumberResult("countNodes('countNodes(2+2)')", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test (expected=ParserException.class)
public void testCountNodesWithWrongInputCharacter() {
Evaluator.getNumberResult("countNodes(ab)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test (expected=FunctionInvalidNumberOfArgumentsException.class)
public void testCountNodesWithTwoArguments() {
Evaluator.getNumberResult("countNodes(3, 2)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test (expected=FunctionInvalidNumberOfArgumentsException.class)
public void testCountNodesWithThreeArguments() {
Evaluator.getNumberResult("countNodes(1, 2, 3)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test (expected=UndefinedExerciseVariableException.class)
public void testCountNodesWithMissingExcerciseVariable() {
Evaluator.getNumberResult("countNodes('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test (expected=UndefinedFillInVariableException.class)
public void testCountNodesWithMissingInput() {
Evaluator.getNumberResult("countNodes('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}
</syntaxhighlight>


=== Hinweise ===
=== Hinweise ===

Version vom 24. September 2018, 11:55 Uhr

Beschreibung

Die Funktion countNodes ruft die Methode getNumberOfNodes des entsprechenden OpenMathObjektes auf und zählt die Knoten des OpenMathObjektes. (In den implementierten OpenMathObjekten ist jedoch diese Funktion nicht implementiert)

Syntax

countNodes(Ausdruck argument)

Parameter

  • argument - die Expression, dessen Knoten gezählt werden sollen

Return Value

  • Gibt die Anzahl der Knoten zurück

Beispiele

Standardfälle

Benutzung mit Variablen

countNodes([pos=1])

countNodes([var=a])

Hinweise