fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / op / sprintf2.t
blobbdaac43442ac3a662ef72415aed4da46c12b0253
1 #!./parrot
2 # Copyright (C) 2001-2010, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/op/sprintf2.t - Auxilliary tests for the sprintf opcode
9 =head1 SYNOPSIS
11     % prove t/op/sprintf2.t
13 =head1 DESCRIPTION
15 Executes sprintf tests.
17 =cut
20 .sub main :main
21     .include 'test_more.pir'
23     plan(9)
25     positive_length()
26     negative_length()
27     minus_option__positive_length()
28     misc_w__minus_option()
29     string__positive_length()
30     string__negative_length()
31     string__minus_flag()
32     float_length_and_prec()
33     float_neg_length_and_prec()
35 .end
37 .sub positive_length
38   $P0 = new 'ResizablePMCArray'
39   push $P0,4
40   push $P0,12
41   $S0 = sprintf '<%*d>', $P0
42   is( $S0, '<  12>', 'positive length' )
43 .end
45 .sub negative_length
46   $P0 = new 'ResizablePMCArray'
47   push $P0,-4
48   push $P0,12
49   $S0 = sprintf '<%*d>', $P0
50   is( $S0, '<12  >', 'negative length' )
51 .end
53 .sub minus_option__positive_length
54   $P0 = new 'ResizablePMCArray'
55   push $P0,4
56   push $P0,12
57   $S0 = sprintf '<%-*d>', $P0
58   is( $S0, '<12  >', 'minus option, positive length' )
59 .end
61 .sub misc_w__minus_option
62   $P0 = new 'ResizablePMCArray'
63   push $P0,65
64   push $P0,65
65   push $P0,65
66   push $P0,65
67   push $P0,65
68   push $P0,65
69   push $P0,3
70   push $P0,65
71   push $P0,-4
72   push $P0,65
73   $S0 = sprintf '|%c|%0c|%-1c|%1c|%-6c|%6c|%*c|%*c|', $P0
74   is( $S0, '|A|A|A|A|A     |     A|  A|A   |', 'misc w/ minus option' )
75 .end
77 .sub string__positive_length
78   $P0 = new 'ResizablePMCArray'
79   push $P0,4
80   push $P0,"hi"
81   $S0 = sprintf '<%*s>', $P0
82   is( $S0, '<  hi>', 'string, positive length' )
83 .end
85 .sub string__negative_length
86   $P0 = new 'ResizablePMCArray'
87   push $P0,-4
88   push $P0,"hi"
89   $S0 = sprintf '<%*s>', $P0
90   is( $S0, '<hi  >', 'string, negative length' )
91 .end
93 .sub string__minus_flag
94   $P0 = new 'ResizablePMCArray'
95   push $P0,4
96   push $P0,"hi"
97   $S0 = sprintf '<%-*s>', $P0
98   is( $S0, '<hi  >', 'string, minus flag' )
99 .end
101 .sub float_length_and_prec
102   $P0 = new 'ResizablePMCArray'
103   push $P0,7
104   push $P0,2
105   push $P0,123.456
106   $S0 = sprintf '<%*.*f>', $P0
107   is( $S0, '< 123.46>', 'float length&prec' )
108 .end
110 .sub float_neg_length_and_prec
111   $P0 = new 'ResizablePMCArray'
112   push $P0,-7
113   push $P0,2
114   push $P0,123.456
115   $S0 = sprintf '<%*.*f>', $P0
116   is( $S0, '<123.46 >', 'float -length&prec' )
117 .end
121 # Local Variables:
122 #   mode: pir
123 #   fill-column: 100
124 # End:
125 # vim: expandtab shiftwidth=4 ft=pir: