Пример #1
0
  public void testUserListReset() {
    dataContainer.addSpriteUserList(SPRITE_USER_LIST_NAME);
    dataContainer.addSpriteUserList(PROJECT_USER_LIST_NAME_2);
    dataContainer.addSpriteUserList(PROJECT_USER_LIST_NAME);

    dataContainer
        .getUserList(SPRITE_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_MULTIPLE_NUMBERS);
    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_MULTIPLE_NUMBERS);
    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME_2, firstSprite)
        .setList(USER_LIST_VALUES_MULTIPLE_NUMBERS);

    dataContainer.resetAllDataObjects();

    assertEquals(
        "Sprite UserList did not reset",
        EMPTY_USER_LIST_INTERPRETATION_VALUE,
        interpretUserList(SPRITE_USER_LIST_NAME));
    assertEquals(
        "Project UserList did not reset",
        EMPTY_USER_LIST_INTERPRETATION_VALUE,
        interpretUserList(PROJECT_USER_LIST_NAME));
    assertEquals(
        "Project UserList 2 did not reset",
        EMPTY_USER_LIST_INTERPRETATION_VALUE,
        interpretUserList(PROJECT_USER_LIST_NAME_2));
  }
Пример #2
0
  public void testFunctionLength() {
    dataContainer.addProjectUserList(PROJECT_USER_LIST_NAME);
    dataContainer.getUserList(PROJECT_USER_LIST_NAME, firstSprite).setList(new ArrayList<Object>());

    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        (double) 0,
        firstSprite);

    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_STRINGS);
    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        (double) USER_LIST_VALUES_STRINGS_LENGTH_INTERPRETATION_VALUE,
        firstSprite);

    ArrayList<Object> userList = new ArrayList<Object>();
    userList.add("0");
    dataContainer.getUserList(PROJECT_USER_LIST_NAME, firstSprite).setList(userList);
    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        (double) 1,
        firstSprite);

    userList.clear();
    userList.add("0.0");
    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        (double) 3,
        firstSprite);

    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH, InternTokenType.NUMBER, "0", (double) 1, firstSprite);

    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH, InternTokenType.NUMBER, "0.0", (double) 3, firstSprite);
  }
Пример #3
0
  public void testUserListInterpretationEmptyList() {
    dataContainer.getUserList(PROJECT_USER_LIST_NAME, firstSprite).getList().clear();

    assertEquals(
        "Formula interpretation of List is not as expected",
        EMPTY_USER_LIST_INTERPRETATION_VALUE,
        (Double) interpretUserList(PROJECT_USER_LIST_NAME),
        DELTA);
  }
Пример #4
0
 public void testUserListInterpretationStringsAndNumbers() {
   dataContainer
       .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
       .setList(USER_LIST_VALUES_STRINGS_AND_NUMBERS);
   assertEquals(
       "Formula interpretation of List is not as expected",
       USER_LIST_VALUES_STRINGS_AND_NUMBERS_INTERPRETATION_VALUE,
       interpretUserList(PROJECT_USER_LIST_NAME));
 }
Пример #5
0
 public void testUserListInterpretationMultipleNumberString() {
   dataContainer
       .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
       .setList(USER_LIST_VALUES_MULTIPLE_NUMBER_STRING);
   assertEquals(
       "Formula interpretation of List is not as expected",
       USER_LIST_VALUES_MULTIPLE_NUMBER_STRING_INTERPRETATION_VALUE,
       interpretUserList(PROJECT_USER_LIST_NAME));
 }
Пример #6
0
  public void testFunctionNumberOfItems() {
    dataContainer.addProjectUserList(PROJECT_USER_LIST_NAME);

    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.NUMBER_OF_ITEMS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        (double) 0,
        firstSprite);

    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_STRINGS);
    FormulaEditorTestUtil.testSingleParameterFunction(
        Functions.LENGTH,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        (double) USER_LIST_VALUES_STRINGS_LENGTH_INTERPRETATION_VALUE,
        firstSprite);
  }
Пример #7
0
  public void testFunctionContains() {
    dataContainer.addProjectUserList(PROJECT_USER_LIST_NAME);
    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_MULTIPLE_NUMBERS);
    dataContainer.addProjectUserVariable(PROJECT_USER_VARIABLE);

    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.CONTAINS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        InternTokenType.NUMBER,
        "1",
        1d,
        firstSprite);

    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.CONTAINS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        InternTokenType.STRING,
        "1",
        1d,
        firstSprite);

    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.CONTAINS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        InternTokenType.STRING,
        "1.00",
        1d,
        firstSprite);

    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.CONTAINS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        InternTokenType.NUMBER,
        "0",
        0d,
        firstSprite);

    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_STRINGS_AND_NUMBERS);

    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.CONTAINS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        InternTokenType.STRING,
        "Hello",
        1d,
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue("Hello");
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.CONTAINS,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        1d,
        firstSprite);
  }
Пример #8
0
  public void testFunctionListItem() {
    dataContainer.addSpriteUserList(PROJECT_USER_LIST_NAME);
    dataContainer
        .getUserList(PROJECT_USER_LIST_NAME, firstSprite)
        .setList(USER_LIST_VALUES_MULTIPLE_NUMBERS);
    dataContainer.addProjectUserVariable(PROJECT_USER_VARIABLE);

    String index = "1";
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.NUMBER,
        index,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        1.0,
        firstSprite);

    index = "0";
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.NUMBER,
        index,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        "",
        firstSprite);

    index = "4";
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.NUMBER,
        index,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        "",
        firstSprite);

    index = "1.4";
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.NUMBER,
        index,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        1.0,
        firstSprite);

    index = "1.0";
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.STRING,
        index,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        1.0,
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue("1");
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        1.0,
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue("0");
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        "",
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue("4");
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        "",
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue(1d);
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        1.0,
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue(0d);
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        "",
        firstSprite);

    dataContainer.getUserVariable(PROJECT_USER_VARIABLE, firstSprite).setValue(4d);
    FormulaEditorTestUtil.testDoubleParameterFunction(
        Functions.LIST_ITEM,
        InternTokenType.USER_VARIABLE,
        PROJECT_USER_VARIABLE,
        InternTokenType.USER_LIST,
        PROJECT_USER_LIST_NAME,
        "",
        firstSprite);
  }