diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-07-25 14:46:59 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-07-27 10:22:23 +0200 |
| commit | 68faa5258297b6ba1a167e8233e59ca2c6b2b995 (patch) | |
| tree | d826029465de57deb3c84218f9475e346f37ecd5 /prog/encoding_test.go | |
| parent | 0889ba7a79553599d0faaf78fb2403b90b1e1be4 (diff) | |
prog: parse comments in serialized programs
Remember per-call comments, will be useful for annotating tests.
Also support this form:
call() # comment
Diffstat (limited to 'prog/encoding_test.go')
| -rw-r--r-- | prog/encoding_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
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) + } + } +} |
