コード例 #1
0
  @Override
  protected void setUp() {
    Project project = new Project(null, "testProject");
    firstSprite = new SingleSprite("firstSprite");
    StartScript startScript = new StartScript();
    ChangeSizeByNBrick changeBrick = new ChangeSizeByNBrick(10);
    firstSprite.addScript(startScript);
    startScript.addBrick(changeBrick);
    project.getDefaultScene().addSprite(firstSprite);
    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(firstSprite);

    dataContainer = ProjectManager.getInstance().getCurrentScene().getDataContainer();
    dataContainer.addProjectUserList(PROJECT_USER_LIST_NAME);
    dataContainer.addSpriteUserListToSprite(firstSprite, SPRITE_USER_LIST_NAME);
    dataContainer.addProjectUserList(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 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);
  }
コード例 #4
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);
  }