@@ -268,6 +268,42 @@ func TestErrBuiltin(t *testing.T) {
268268 test ("atomicLoad" , func (ctx * context ) { ctx .atomicLoad (nil , nil ) })
269269 test ("atomicStore" , func (ctx * context ) { ctx .atomicStore (nil , nil ) })
270270 test ("atomicCmpXchg" , func (ctx * context ) { ctx .atomicCmpXchg (nil , nil ) })
271+
272+ }
273+
274+ func TestErrAsm (t * testing.T ) {
275+ test := func (testName string , fn func (ctx * context )) {
276+ defer func () {
277+ if r := recover (); r == nil {
278+ t .Fatal (testName , ": no error?" )
279+ }
280+ }()
281+ var ctx context
282+ fn (& ctx )
283+ }
284+
285+ test ("asm(NoArgs)" , func (ctx * context ) { ctx .asm (nil , []ssa.Value {}) })
286+ test ("asm(Nonconst)" , func (ctx * context ) { ctx .asm (nil , []ssa.Value {& ssa.Parameter {}}) })
287+ test ("asmFull(NonConstKey)" , func (ctx * context ) {
288+ makeMap := & ssa.MakeMap {}
289+ nonConstKey := & ssa.Parameter {}
290+ mapUpdate := & ssa.MapUpdate {Key : nonConstKey }
291+ referrers := []ssa.Instruction {mapUpdate }
292+ setRefs (unsafe .Pointer (makeMap ), referrers ... )
293+ strConst := & ssa.Const {
294+ Value : constant .MakeString ("nop" ),
295+ }
296+ ctx .asm (nil , []ssa.Value {strConst , makeMap })
297+ })
298+ test ("asmFull(RegisterNotFound)" , func (ctx * context ) {
299+ makeMap := & ssa.MakeMap {}
300+ referrers := []ssa.Instruction {}
301+ setRefs (unsafe .Pointer (makeMap ), referrers ... )
302+ strConst := & ssa.Const {
303+ Value : constant .MakeString ("test {missing}" ),
304+ }
305+ ctx .asm (nil , []ssa.Value {strConst , makeMap })
306+ })
271307}
272308
273309func TestPkgNoInit (t * testing.T ) {
0 commit comments