develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35034 - branches/bcanno/t/op

From:
jonathan
Date:
January 6, 2009 05:53
Subject:
[svn:parrot] r35034 - branches/bcanno/t/op
Message ID:
20090106135343.239C2CB9F9@x12.develooper.com
Author: jonathan
Date: Tue Jan  6 05:53:42 2009
New Revision: 35034

Added:
   branches/bcanno/t/op/annotate.t   (contents, props changed)

Log:
[t] Add tests for bytecode annotations and exceptions.

Added: branches/bcanno/t/op/annotate.t
==============================================================================
--- (empty file)
+++ branches/bcanno/t/op/annotate.t	Tue Jan  6 05:53:42 2009
@@ -0,0 +1,79 @@
+#! parrot
+# Copyright (C) 2009, The Perl Foundation.
+# $Id$
+
+=head1 NAME
+
+t/op/annotate.t - Test .annotate directive
+
+=head1 SYNOPSIS
+
+    % prove t/op/annotate.t
+
+=head1 DESCRIPTION
+
+Test various use cases of the annotate directive.
+
+=cut
+
+.sub main :main
+    .include 'include/test_more.pir'
+
+    plan(8)
+
+    'no_annotations'()
+    'annotations_exception'()
+.end
+
+
+.sub 'no_annotations'
+    push_eh failed
+    die "OH NOES!"
+
+  failed:
+    .local pmc exception
+    .get_results (exception)
+    $P0 = exception.'annotations'()
+    isa_ok ($P0, 'Hash', 'annotations gives back hash')
+    $I0 = elements $P0
+    is ($I0, 0, 'annotations hash empty when none in effect')
+    $P0 = exception.'annotations'('line')
+    $I0 = isnull $P0
+    ok ($I0, 'get null PMC when no annotation in effect')
+.end
+
+
+.sub 'annotations_exception'
+    .annotate "file", "foo.p6"
+    .annotate "line", 1
+    push_eh failed
+    .annotate "line", 2
+    $S0 = "OMGWTFBBQ"
+    die $S0
+    .annotate "line", 3
+
+  failed:
+    .local pmc exception
+    .get_results (exception)
+
+    $P0 = exception.'annotations'('file')
+    is ($P0, 'foo.p6', "file annotation got OK")
+    $P0 = exception.'annotations'('line')
+    is ($P0, 2, "line annotation got OK")
+
+    $P0 = exception.'annotations'()
+    isa_ok ($P0, 'Hash', 'annotations gives back hash')
+    $I0 = elements $P0
+    is ($I0, 2, 'annotations hash is right size')
+    $P1 = $P0["file"]
+    is ($P1, 'foo.p6', "file annotation got OK from hash")
+    $P1 = $P0["line"]
+    is ($P1, 2, "line annotation got OK from hash")
+.end
+
+
+# Local Variables:
+#   mode: pir 
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About