-
Notifications
You must be signed in to change notification settings - Fork 5
/
car_atom_bug_he_621.metta
50 lines (43 loc) · 1.94 KB
/
car_atom_bug_he_621.metta
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
; Test File: car-atom Bug in MeTTa
; Bug Report: https://github.com/trueagi-io/hyperon-experimental/issues/621
; Issue Overview:
; The `car-atom` function raises an error on some non-empty expressions. This issue is observed
; when `stringToChars` is used in conjunction with `car-atom`.
; Example 1: Using `car-atom` Directly
; ------------------------------------
; Test: `car-atom` on a manually created non-empty list
!(assertEqualToResult
(car-atom ('a' 'b'))
('a'))
; Explanation:
; The input `('a' 'b')` is a valid non-empty list. The result should be the first element, `['a']`.
; Example 2: Using `stringToChars` with `car-atom`
; -----------------------------------------------
; Test: Converting a string to a list of characters and applying `car-atom`
!(assertEqualToResult
(let $s (stringToChars "ab") (car-atom $s))
('a'))
; Explanation:
; The function `stringToChars` correctly converts `"ab"` into `('a' 'b')`. Applying `car-atom` to this
; list should return the first element, `['a']`.
; Expected Behavior:
; - `car-atom` should seamlessly handle non-empty expressions resulting from `stringToChars`.
; Example 3: Direct `stringToChars` Output
; ----------------------------------------
; Test: Ensure `stringToChars` outputs the expected list of characters
!(assertEqualToResult
(stringToChars "ab")
(('a' 'b')))
; Explanation:
; The function `stringToChars` converts `"ab"` into `('a' 'b')`.
; Example 4: Combining Manually Created and Generated Lists
; ---------------------------------------------------------
; Test: Manually creating a list and applying `car-atom`
!(assertEqualToResult
(let $s ('a' 'b') (car-atom $s))
('a'))
; Explanation:
; The manually created list `('a' 'b')` works correctly with `car-atom`.
; Summary:
; - The bug occurs specifically when the list is generated by `stringToChars` and passed to `car-atom`.
; - Expected behavior is that `car-atom` treats generated lists and manually created lists identically.