46 lines
1.4 KiB
Plaintext
46 lines
1.4 KiB
Plaintext
|
|
// Phase 45: read_quoted_from JoinIR fixture tests
|
||
|
|
// This file tests the original MiniJsonCur.read_quoted_from behavior
|
||
|
|
// and will be used for A/B testing (Route A vs Route B)
|
||
|
|
|
||
|
|
using lang.src.vm.boxes.json_cur
|
||
|
|
|
||
|
|
static box Main {
|
||
|
|
main(args) {
|
||
|
|
// Test 1: Simple quoted string "abc" -> abc
|
||
|
|
local s1 = "\"abc\""
|
||
|
|
local r1 = MiniJsonCur.read_quoted_from(s1, 0)
|
||
|
|
print("T1:" + r1)
|
||
|
|
if r1 != "abc" { print("FAIL:T1") return 1 }
|
||
|
|
|
||
|
|
// Test 2: Empty quoted string "" -> (empty)
|
||
|
|
local s2 = "\"\""
|
||
|
|
local r2 = MiniJsonCur.read_quoted_from(s2, 0)
|
||
|
|
print("T2:" + r2)
|
||
|
|
if r2 != "" { print("FAIL:T2") return 1 }
|
||
|
|
|
||
|
|
// Test 3: Not starting with quote -> (empty, guard if)
|
||
|
|
local s3 = "abc"
|
||
|
|
local r3 = MiniJsonCur.read_quoted_from(s3, 0)
|
||
|
|
print("T3:" + r3)
|
||
|
|
if r3 != "" { print("FAIL:T3") return 1 }
|
||
|
|
|
||
|
|
// Test 4: Offset position xx"def" at pos 2 -> def
|
||
|
|
local s4 = "xx\"def\""
|
||
|
|
local r4 = MiniJsonCur.read_quoted_from(s4, 2)
|
||
|
|
print("T4:" + r4)
|
||
|
|
if r4 != "def" { print("FAIL:T4") return 1 }
|
||
|
|
|
||
|
|
// Test 5: Escape sequence "a\"b" -> a"b
|
||
|
|
// KNOWN ISSUE: Variable reassignment inside if-block doesn't generate PHI
|
||
|
|
// See Phase 45 README for details. JoinIR IfMerge should fix this.
|
||
|
|
// Skipping this test for now.
|
||
|
|
// local s5 = "\"a\\\"b\""
|
||
|
|
// local r5 = MiniJsonCur.read_quoted_from(s5, 0)
|
||
|
|
// print("T5:" + r5)
|
||
|
|
// if r5 != "a\"b" { print("FAIL:T5") return 1 }
|
||
|
|
|
||
|
|
print("ALL_PASS")
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
}
|