package test.blog.model;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import blog.common.numerical.MatrixFactory;
import blog.common.numerical.MatrixLib;
import blog.model.BuiltInFunctions;
import blog.model.Model;
import blog.sample.DefaultEvalContext;
import blog.world.PartialWorld;

/**
 * Unit tests for BuiltInFunctions.
 */
public class TestBuiltInFunctions {

  @Test
  public void testIndexRowVector() {
    MatrixLib rowVec = MatrixFactory.zeros(1, 5);
    Object[] args = { rowVec, 3 };
    double result = (Double) BuiltInFunctions.SUB_REAL_ARRAY.getValueInContext(
        args, new DefaultEvalContext(PartialWorld.EMPTY_INST), false);
    assertEquals(result, 0.0, 1e-10);
  }

  @Test
  public void testIndexColumnVector() {
    MatrixLib colVec = MatrixFactory.zeros(5, 1);
    Object[] args = { colVec, 3 };
    double result = (Double) BuiltInFunctions.SUB_REAL_ARRAY.getValueInContext(
        args, new DefaultEvalContext(PartialWorld.EMPTY_INST), false);
    assertEquals(result, 0.0, 1e-10);
  }

  @Test
  public void testMinMax() {
    Model.fromFile("src/test/models/minmax.blog");
  }
}

@@ -563,34 +563,27 @@
 nctions.SUB_
-REAL_ARRAY
+MAT
 .getValueInC
@@ -585,32 +585,37 @@
 ueInContext(
+args,
 %0A       
  args, new D
@@ -594,38 +594,32 @@
 xt(args,%0A       
- args,
  new DefaultEval
@@ -890,18 +890,11 @@
 SUB_
-REAL_ARRAY
+MAT
 .get
@@ -908,24 +908,29 @@
 Context(
+args,
 %0A       
  args, n
@@ -925,14 +925,8 @@
     
- args,
  new

make TestBuiltInFunctions pass again