github.com/haraldrudell/parl@v0.4.176/pruntime/cached-location_test.go (about) 1 /* 2 © 2021–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package pruntime 7 8 import ( 9 "testing" 10 ) 11 12 func TestCachedLocation(t *testing.T) { 13 var c CachedLocation 14 var exp string 15 16 // initial Short should match CodeLocation 17 var cL, act = NewCodeLocation(0), c.Short() 18 if exp = cL.Short(); act != exp { 19 t.Errorf("initial Short: %q exp %q", act, exp) 20 } 21 22 // cached Short should match Code Location 23 if act, exp = c.Short(), cL.Short(); act != exp { 24 t.Errorf("cached Short: %q exp %q", act, exp) 25 } 26 27 // FuncIdentifier 28 if act, exp = c.FuncIdentifier(), cL.FuncIdentifier(); act != exp { 29 t.Errorf("FuncIdentifier: %q exp %q", act, exp) 30 } 31 32 // FuncName 33 if act, exp = c.FuncName(), cL.FuncName; act != exp { 34 t.Errorf("FuncName: %q exp %q", act, exp) 35 } 36 37 // PackFunc 38 if act, exp = c.PackFunc(), cL.PackFunc(); act != exp { 39 t.Errorf("PackFunc: %q exp %q", act, exp) 40 } 41 }