feat: move contains method from List to Sequence and add tests for List and Range

Add a generic `contains` implementation on the `Sequence` base class, removing the duplicate method from `List`. This allows all sequence types (including Range) to use the method without per-class redefinition. Include new test files for `List.contains` and `Range.contains` covering ordered, backwards, and exclusive ranges.
This commit is contained in:
Thorbjørn Lindeijer
2015-03-15 14:43:10 +00:00
parent 18cf57d5f5
commit b22040577e
5 changed files with 51 additions and 18 deletions
+9 -9
View File
@@ -45,6 +45,15 @@
// This string literal is generated automatically from core. Do not edit.
static const char* libSource =
"class Sequence {\n"
" contains(element) {\n"
" for (item in this) {\n"
" if (element == item) {\n"
" return true\n"
" }\n"
" }\n"
" return false\n"
" }\n"
"\n"
" count {\n"
" var result = 0\n"
" for (element in this) {\n"
@@ -138,15 +147,6 @@ static const char* libSource =
" }\n"
" return result\n"
" }\n"
"\n"
" contains(element) {\n"
" for (item in this) {\n"
" if (element == item) {\n"
" return true\n"
" }\n"
" }\n"
" return false\n"
" }\n"
"}\n"
"\n"
"class Map {\n"