File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -362,7 +362,9 @@ void bind_ast(py::module_ &m) {
362
362
py::class_<kore_string_pattern, std::shared_ptr<kore_string_pattern>>(
363
363
ast, " StringPattern" , pattern_base)
364
364
.def (py::init (&kore_string_pattern::create))
365
- .def_property_readonly (" contents" , &kore_string_pattern::get_contents);
365
+ .def_property_readonly (" contents" , [](kore_string_pattern &pattern) {
366
+ return py::bytes (pattern.get_contents ());
367
+ });
366
368
}
367
369
368
370
void bind_parser (py::module_ &mod) {
Original file line number Diff line number Diff line change @@ -36,7 +36,19 @@ def test_composite(self):
36
36
def test_string (self ):
37
37
pat = kllvm .ast .StringPattern ("abc" )
38
38
self .assertEqual (str (pat ), '"abc"' )
39
- self .assertEqual (pat .contents , "abc" )
39
+ self .assertEqual (pat .contents .decode ('raw_unicode_escape' ), "abc" )
40
+
41
+ def test_string_escape (self ):
42
+ value_encoded = r'\t\n\r\f\\\"' .encode ('raw_unicode_escape' )
43
+ pat = kllvm .ast .StringPattern (value_encoded )
44
+ self .assertEqual (pat .contents , value_encoded )
45
+ self .assertEqual (value_encoded .decode ('raw_unicode_escape' ), r'\t\n\r\f\\\"' )
46
+
47
+ def test_string_unicode (self ):
48
+ value_encoded = r'\u03b1' .encode ('raw_unicode_escape' )
49
+ pat = kllvm .ast .StringPattern (value_encoded )
50
+ self .assertEqual (pat .contents , value_encoded )
51
+ self .assertEqual (value_encoded .decode ('raw_unicode_escape' ), r'α' )
40
52
41
53
def test_variable (self ):
42
54
pat = kllvm .ast .VariablePattern ("A" , kllvm .ast .CompositeSort ("S" ))
You can’t perform that action at this time.
0 commit comments