# Tests/100-basics/063-esc-string-subst.cobra # Tests for escaping of substitution syntax in strings # By hopscc #.require. clr class Test def main is shared a = 99 s0 = "a = [a]" assert s0 == "a = 99" s1 = "1:a = \[..[a]..]" assert s1 == r"1:a = [..99..]" s2 = "2:a = \[[a]]" assert s2 == r"2:a = [99]" s2a = "2:a = \\[a]" assert s2a == r"2:a = \99" s3 = "3:a = \[xx: [a]]" assert s3 == r"3:a = [xx: 99]" s4 = "4:a = \[33xx: [a]]" assert s4 == r"4:a = [33xx: 99]" s4a = '4:a = \[33xx: [a]]' assert s4a == r'4:a = [33xx: 99]' s5 = "4a:a = \[33xx] \[yy]: [a]]" assert s5 == r"4a:a = [33xx] [yy]: 99]" s6 = "5:a = \[valueof(a)] \[b]" assert s6 == r"5:a = [valueof(a)] [b]" s7 = "6:a = [a] a = \[..] [a] " assert s7 == r"6:a = 99 a = [..] 99 " s7a = "7: \[a = ][a]] bigjobs \[[a]] crivens" assert s7a == r'7: [a = ]99] bigjobs [99] crivens' s8 = ns"7:a = \[a][a]" assert s8 == r"7:a = [a][a]" s9 = r"8:a = \[[a]]" assert s9 == r"8:a = \[[a]]" s10 = 'FMT:a = '+ ns'[' +'[a]]' assert s10 == r'FMT:a = [99]' s12 = 'a = [c'['][a]]' assert s12 == r'a = [99]' b = ns"\\[" assert b == r'\[' assert b == r"\[" assert b <> r'\\{' b2 = "123 \[ 456" assert b2 == r"123 [ 456" b2 = '123 \[ 456' assert b2 == r"123 [ 456" b3 = r'123 \[ 456' assert b3 == r"123 \[ 456"