-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved support for item selector expressions (fix for #124)
- Loading branch information
Showing
5 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
....test.acceptance/src/org/eclipse/epsilon/eol/engine/test/acceptance/ItemSelectorTests.eol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@test | ||
operation testExistingIndexInSet() { | ||
assertEquals(1, Set{1, 2}[0]); | ||
} | ||
|
||
@test | ||
operation testExistingIndexInSequence() { | ||
assertEquals(1, Sequence{1, 2}[0]); | ||
} | ||
|
||
@test | ||
operation testIndexOutOfBoundsInCollection() { | ||
assertError(Sequence{1, 2}[2]); | ||
} | ||
|
||
@test | ||
operation testExistingKeyInMap() { | ||
assertEquals(1, Map{"a" = 1}["a"]); | ||
} | ||
|
||
@test | ||
operation testExistingKeyInNativeMap() { | ||
assertEquals(1, createNativeMap()["a"]); | ||
} | ||
|
||
@test | ||
operation testUnknownKeyInMap() { | ||
assertEquals(null, Map{"a" = 1}["b"]); | ||
} | ||
|
||
@test | ||
operation testAssignToListIndex() { | ||
var s = Sequence{1, 2}; | ||
s[0] = 3; | ||
assertEquals(3, s[0]); | ||
} | ||
|
||
@test | ||
operation testAssignToExistingMapKey() { | ||
var m = Map{"a" = 1}; | ||
m["a"] = 2; | ||
assertEquals(2, m["a"]); | ||
} | ||
|
||
@test | ||
operation testAssignToExistingNativeMapKey() { | ||
var m = createNativeMap(); | ||
m["a"] = 2; | ||
assertEquals(2, m["a"]); | ||
} | ||
|
||
@test | ||
operation testAssignToNewMapKey() { | ||
var m = Map{"a" = 1}; | ||
m["b"] = 2; | ||
assertEquals(2, m["b"]); | ||
} | ||
|
||
@test | ||
operation testAssignToSetIndex() { | ||
assertError(assignToSetIndex()); | ||
} | ||
|
||
operation assignToSetIndex() { | ||
var s = Set{1, 2}; | ||
// This is not allowed as Set is not a java.util.List | ||
s[0] = 3; | ||
} | ||
|
||
operation createNativeMap() { | ||
var m = new Native("java.util.HashMap"); | ||
m.put("a", 1); | ||
return m; | ||
} |
19 changes: 19 additions & 0 deletions
19
...test.acceptance/src/org/eclipse/epsilon/eol/engine/test/acceptance/ItemSelectorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2008 The University of York. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* Contributors: | ||
* Dimitrios Kolovos - initial API and implementation | ||
******************************************************************************/ | ||
package org.eclipse.epsilon.eol.engine.test.acceptance; | ||
|
||
import org.eclipse.epsilon.eol.engine.test.acceptance.eunit.EUnitRunner; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(EUnitRunner.class) | ||
public class ItemSelectorTests { | ||
|
||
} | ||
|