|
| 1 | +class_name TestMap |
| 2 | + |
| 3 | +func _init() -> void: |
| 4 | + pass |
| 5 | + |
| 6 | +static func test() -> void: |
| 7 | + var m: StringMap = StringMap.new() |
| 8 | + var _g: IntMap = IntMap.new() |
| 9 | + |
| 10 | + _g.__set(123, "123") |
| 11 | + _g.__set(321, "321") |
| 12 | + m.__set("a", 1) |
| 13 | + m.__set("b", 2) |
| 14 | + |
| 15 | + var tempNumber: int = 2 |
| 16 | + |
| 17 | + tempNumber |
| 18 | + |
| 19 | + if true: |
| 20 | + var cond: bool = m.__get("a") == 1 |
| 21 | + assert(cond, "Test assert failed.") |
| 22 | + if true: |
| 23 | + var cond: bool = m.__get("b") == 2 |
| 24 | + assert(cond, "Test assert failed.") |
| 25 | + if true: |
| 26 | + var cond: bool = _g.__get(321) == "321" |
| 27 | + assert(cond, "Test assert failed.") |
| 28 | + |
| 29 | + var m3: StringMap = m.copy() |
| 30 | + |
| 31 | + if true: |
| 32 | + var cond: bool = m3.__get("a") == 1 |
| 33 | + assert(cond, "Test assert failed.") |
| 34 | + if true: |
| 35 | + var cond: bool = m3.__get("b") == 2 |
| 36 | + assert(cond, "Test assert failed.") |
| 37 | + |
| 38 | + m3.clear() |
| 39 | + |
| 40 | + if true: |
| 41 | + var cond: bool = !m3.exists("a") |
| 42 | + assert(cond, "Test assert failed.") |
| 43 | + if true: |
| 44 | + var cond: bool = m.exists("a") |
| 45 | + assert(cond, "Test assert failed.") |
| 46 | + if true: |
| 47 | + var cond: bool = !m.exists("c") |
| 48 | + assert(cond, "Test assert failed.") |
| 49 | + if true: |
| 50 | + var cond: bool = _g.exists(123) |
| 51 | + assert(cond, "Test assert failed.") |
| 52 | + if true: |
| 53 | + var cond: bool = !_g.exists(124) |
| 54 | + assert(cond, "Test assert failed.") |
| 55 | + |
| 56 | + m.remove("a") |
| 57 | + |
| 58 | + if true: |
| 59 | + var cond: bool = !m.exists("a") |
| 60 | + assert(cond, "Test assert failed.") |
| 61 | + |
| 62 | + Log.trace.call(m.toString(), { |
| 63 | + "fileName": "src/test/TestMap.hx", |
| 64 | + "lineNumber": 40, |
| 65 | + "className": "test.TestMap", |
| 66 | + "methodName": "test" |
| 67 | + }) |
0 commit comments