@@ -31,7 +31,7 @@ extension InputHandlerTests {
3131 /// - Parameters:
3232 /// - thePrefix: 要測試的前綴。
3333 /// - Warning: This unit test case is not designed for dynamic phonabet layouts.
34- @Test ( arguments: [ " " , " ai " , " AI " , " hello " , " Hello " ] )
34+ @Test ( arguments: [ " " , " ai " , " ello " , " cOS " ] )
3535 func test_IH400_MixedAlnumKanjiInputTest_Izanami(
3636 _ thePrefix: String
3737 ) throws {
@@ -1163,6 +1163,69 @@ extension InputHandlerTests {
11631163 #expect( testHandler. committableDisplayText ( sansReading: true ) == " 這 " , " 5k4 應為 ㄓㄜˋ=這 " )
11641164 }
11651165
1166+ // MARK: — camelCase 後綴不得被誤判為注音
1167+
1168+ /// camelCase 英文詞中大寫字母不得被 auto-split 誤判為注音後綴。
1169+ /// 此測試鎖住 bug:`macOS ` 被誤拆成 `ma` + 注音後綴 `OS`。
1170+ @Test
1171+ func test_IH429_MixedCamelCaseSuffixNotTreatedAsPhonetic( ) throws {
1172+ let ( testHandler, testSession) = try prepareMixedModeHandler ( )
1173+
1174+ // macOS:大寫後綴 "OS" 不得被當作注音
1175+ typeSentence ( " macOS " )
1176+ #expect( testSession. recentCommissions. joined ( ) == " macOS " )
1177+ #expect( testHandler. mixedAlphanumericalBuffer. isEmpty)
1178+ #expect( testHandler. composer. isEmpty)
1179+
1180+ testHandler. clear ( )
1181+ testSession. recentCommissions. removeAll ( )
1182+
1183+ // This:大寫開頭的純 ASCII 單字應維持完整
1184+ typeSentence ( " This " )
1185+ #expect( testSession. recentCommissions. joined ( ) == " This " )
1186+ #expect( testHandler. mixedAlphanumericalBuffer. isEmpty)
1187+ #expect( testHandler. composer. isEmpty)
1188+ }
1189+
1190+ // MARK: — CamelCase 縮寫作為 ASCII 前綴 + 注音後綴
1191+
1192+ /// camelCase 縮寫(如 cOS / macOS)作為 ASCII 前綴時,
1193+ /// 後續注音輸入應正確拆分,而非整段被當作 ASCII 提交。
1194+ @Test
1195+ func test_IH430_MixedCamelCasePrefixWithPhoneticSuffix( ) throws {
1196+ let ( testHandler, testSession) = try prepareMixedModeHandler ( )
1197+ testHandler. currentLM. setOptions { cfg in
1198+ cfg. alwaysSupplyETenDOSUnigrams = true
1199+ }
1200+
1201+ // cOS + ㄆ(Dachen26 鍵序 q )
1202+ typeSentence ( " cOSq " )
1203+ let allCommissions = testSession. recentCommissions. joined ( )
1204+ #expect( allCommissions. contains ( " cOS " ) , " cOS prefix should be committed as ASCII " )
1205+ #expect( testHandler. assembler. length == 1 , " Assembler should have one reading " )
1206+ #expect( testHandler. assembler. actualKeys. last == " ㄆ " , " Reading should be ㄆ " )
1207+
1208+ testHandler. clear ( )
1209+ testSession. resetInputHandler ( forceComposerCleanup: true )
1210+
1211+ // macOS + ㄆ(Dachen26 鍵序 q )
1212+ typeSentence ( " macOSq " )
1213+ let allCommissions2 = testSession. recentCommissions. joined ( )
1214+ #expect( allCommissions2. contains ( " macOS " ) , " macOS prefix should be committed as ASCII " )
1215+ #expect( testHandler. assembler. length == 1 , " Assembler should have one reading " )
1216+ #expect( testHandler. assembler. actualKeys. last == " ㄆ " , " Reading should be ㄆ " )
1217+
1218+ testHandler. clear ( )
1219+ testSession. resetInputHandler ( forceComposerCleanup: true )
1220+
1221+ // cOS + ㄇㄛ(Dachen26 鍵序 ai )
1222+ typeSentence ( " cOSai " )
1223+ let allCommissions3 = testSession. recentCommissions. joined ( )
1224+ #expect( allCommissions3. contains ( " cOS " ) , " cOS prefix should be committed as ASCII " )
1225+ #expect( testHandler. assembler. length == 1 , " Assembler should have one reading " )
1226+ #expect( testHandler. assembler. actualKeys. last == " ㄇㄛ " , " Reading should be ㄇㄛ " )
1227+ }
1228+
11661229 // MARK: - Fileprivate Helpers.
11671230
11681231 fileprivate func prepareMixedModeHandler( ) throws -> ( handler: MockInputHandler , session: MockSession ) {
0 commit comments