From 68faa5258297b6ba1a167e8233e59ca2c6b2b995 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 25 Jul 2018 14:46:59 +0200 Subject: prog: parse comments in serialized programs Remember per-call comments, will be useful for annotating tests. Also support this form: call() # comment --- prog/encoding_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'prog/encoding_test.go') diff --git a/prog/encoding_test.go b/prog/encoding_test.go index c641fd5e6..7ecd811bc 100644 --- a/prog/encoding_test.go +++ b/prog/encoding_test.go @@ -303,3 +303,35 @@ func testSerializeDeserialize(t *testing.T, p0 *Prog, data0, data1 []byte) (bool } return true, 0, 0 } + +func TestDeserializeComments(t *testing.T) { + target := initTargetTest(t, "test", "64") + p, err := target.Deserialize([]byte(` +# comment1 +# comment2 +serialize0() +serialize0() +# comment3 +serialize0() +# comment4 +serialize0() # comment5 +#comment6 + +serialize0() +#comment7 +`)) + if err != nil { + t.Fatal(err) + } + for i, want := range []string{ + "comment2", + "", + "comment3", + "comment5", + "", + } { + if got := p.Calls[i].Comment; got != want { + t.Errorf("bad call %v comment: %q, want %q", i, got, want) + } + } +} -- cgit mrf-deployment