Created
November 6, 2010 17:12
-
-
Save koba04/665542 to your computer and use it in GitHub Desktop.
配列にundefなどを追加してみるテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use utf8; | |
use strict; | |
use warnings; | |
use Test::More; | |
my @list = (1..3); | |
# 空リストをpushしても追加されない | |
push @list, (); | |
is(scalar @list, 3, 'push ()'); | |
# myで宣言しただけの配列は追加されない | |
my @list2; | |
push @list, @list2; | |
is(scalar @list, 3, 'push my @list2'); | |
# undefをpushするとundefが追加される | |
push @list, undef; | |
is(scalar @list, 4, 'push undef'); | |
is($list[3], undef, 'list[3] is undef'); | |
# (undef)をpushするとundefが追加される | |
push @list, (undef); | |
is(scalar @list, 5, 'push (undef)'); | |
is($list[4], undef, 'list[4] is undef'); | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment