You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGeneratorTest.kt
+11
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,9 @@ class EnumGeneratorTest {
50
50
{ value: "some-value-2",
51
51
name: "someName2",
52
52
documentation: "More documentation #escape" },
53
+
{ value: "2D_BARCODE",
54
+
name: "_2D_BARCODE",
55
+
documentation: "Example with leading digit." },
53
56
{ value: "unknown",
54
57
name: "unknown",
55
58
documentation: "It has some docs that #need to be escaped" }
@@ -80,6 +83,14 @@ class EnumGeneratorTest {
80
83
}
81
84
}
82
85
86
+
@Test
87
+
fun`it prefixes enum names with underscore to avoid generating invalid identifiers starting with a digit`() {
88
+
model("_2D_BARCODE").also { member ->
89
+
member.derivedName() shouldBe "_2DBarcode"
90
+
member.name()!!.renamedFrom shouldBe "2DBarcode"
91
+
}
92
+
}
93
+
83
94
@Test
84
95
fun`it should render documentation`() {
85
96
val rendered =RustWriter.forModule("model").also { model("some_name_1").render(it) }.toString()
0 commit comments