AtlatestRepositorysigil-http

sigil-http / treetest-list-issue.sgl

1;;; Test file to isolate the list function issue
2
3(import (sigil string))
4
5(display "=== Testing list function ===") (newline)
6
7;; Test 1: Basic list with literals
8(display "Test 1: (list 1 2 3)") (newline)
9(display "Result: ") (display (list 1 2 3)) (newline)
10(newline)
12;; Test 2: List with symbols and #f
13(display "Test 2: (list 'GET \"/\" #f \"HTTP/1.1\")") (newline)
14(display "Result: ") (display (list 'GET "/" #f "HTTP/1.1")) (newline)
15(newline)
17;; Test 3: List with variables
18(display "Test 3: Variables like parse-request-line") (newline)
19(let ((method 'GET)
20 (uri "/")
21 (version "HTTP/1.1"))
22 (display "method=") (display method) (newline)
23 (display "uri=") (display uri) (newline)
24 (display "version=") (display version) (newline)
25 (display "Calling (list method uri #f version)...") (newline)
26 (display "Result: ") (display (list method uri #f version)) (newline))
27(newline)
29;; Test 4: Simulate parse-request-line more closely
30(display "Test 4: Simulating parse-request-line") (newline)
31(define (parse-method str)
32 (cond
33 ((string=? str "GET") 'GET)
34 ((string=? str "POST") 'POST)
35 (else #f)))
37(let ((parts (string-split "GET /path HTTP/1.1" " ")))
38 (display "parts: ") (display parts) (newline)
39 (let ((method-str (car parts)))
40 (display "method-str: ") (display method-str) (newline)
41 (let ((method (parse-method method-str))
42 (uri (cadr parts))
43 (version (caddr parts)))
44 (display "method=") (display method) (newline)
45 (display "uri=") (display uri) (newline)
46 (display "version=") (display version) (newline)
47 (display "Building list...") (newline)
48 (let ((result (list method uri #f version)))
49 (display "Result: ") (display result) (newline)))))
50(newline)
52(display "=== All tests completed ===") (newline)