Codebase list libdata-printer-perl / ad2a477
"123\n" is a string, not a number Ivan Bessarabov 8 years ago
2 changed file(s) with 15 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
370370 ( \. [0-9]+ )? # there can be decimal part, which is optional
371371
372372 ( e [+-] [0-9]+ )? # then there can be optional exponential notation part
373 $
373 \z
374374 /x;
375375
376376 return $is_number;
4040 "NaN",
4141 "abc",
4242 '1_000',
43 '123\n',
44 "123\n",
4345 );
4446
4547 foreach my $not_a_number (@strings) {
48
49 # If we don't change new line symbol then the test output will be messy:
50 #
51 # ok 20 - _is_number('1_000') return false
52 # ok 21 - _is_number('123
53 # # ') return false
54 # 1..21
55
56 my $number_for_test_name = $not_a_number;
57 $number_for_test_name =~ s/\n/\\n/g;
58
4659 ok(
4760 not(Data::Printer::_is_number($not_a_number)),
48 "_is_number('$not_a_number') return false",
61 "_is_number('$number_for_test_name') return false",
4962 );
5063 }
5164