コード例 #1
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);
  }
コード例 #2
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);
  }