Skip to content

Commit cf7ede2

Browse files
committed
Add escaped quote tests for tagged literal handlers
Tests the full pipeline for escaped quotes in #re and #b: tokenizer preserves backslash-quote in raw content, handler interprets it as a literal quote in the output. Also fixes scanRegexContents javadoc.
1 parent 5b43179 commit cf7ede2

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

smithy-model/src/test/java/software/amazon/smithy/model/loader/TaggedStringLiteralTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static Stream<Arguments> reTagTests() {
2929
Arguments.of("\\w+\\s\\d", "\\w+\\s\\d"),
3030
Arguments.of("\\\\", "\\"),
3131
Arguments.of("\\\"", "\""),
32+
Arguments.of("a\\\"b", "a\"b"),
3233
Arguments.of("hello", "hello"),
3334
Arguments.of("", ""),
3435
Arguments.of("[a-z]+\\.(\\d{1,3}\\.){3}\\d{1,3}", "[a-z]+\\.(\\d{1,3}\\.){3}\\d{1,3}"));
@@ -78,6 +79,8 @@ public static Stream<Arguments> bTagTests() {
7879
Arguments.of("\\377", base64((byte) 0xFF)), // max single byte
7980
Arguments.of("\\7", base64((byte) 7)), // single octal digit
8081
Arguments.of("\\77", base64((byte) 63)), // two octal digits
82+
// Escaped quote
83+
Arguments.of("a\\\"b", base64((byte) 'a', (byte) '"', (byte) 'b')),
8184
Arguments.of("", base64()));
8285
}
8386

smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/2.1/tagged-literals.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"smithy.api#pattern": "\\w+"
1414
}
1515
},
16+
"smithy.example#QuoteInRegex": {
17+
"type": "string",
18+
"traits": {
19+
"smithy.api#pattern": "a\"b"
20+
}
21+
},
1622
"smithy.example#TaggedLiteralsExample": {
1723
"type": "structure",
1824
"members": {
@@ -28,6 +34,12 @@
2834
"smithy.api#default": "LlBORw0KGgo="
2935
}
3036
},
37+
"quoted": {
38+
"target": "smithy.api#Blob",
39+
"traits": {
40+
"smithy.api#default": "YSJi"
41+
}
42+
},
3143
"header": {
3244
"target": "smithy.api#Blob",
3345
"traits": {

smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/2.1/tagged-literals.smithy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ string Ssn
88
@pattern(#re "\w+")
99
string Word
1010

11+
@pattern(#re "a\"b")
12+
string QuoteInRegex
13+
1114
structure TaggedLiteralsExample {
1215
@default(#timestamp "2024-01-01T00:00:00Z")
1316
startDate: Timestamp
1417

1518
@default(#b ".PNG\x0D\x0A\x1A\x0A")
1619
avatar: Blob
1720

21+
@default(#b "a\"b")
22+
quoted: Blob
23+
1824
@default(#hex "89504e47")
1925
header: Blob
2026
}

0 commit comments

Comments
 (0)