"Assert"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[category: Error]]
[[category: Error]]
;assert
;die


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
assert 1 == 1
assert 1 == 1
assert 1 == 2
assert 1 == 2
# AssertionError
# AssertionError
</source>
</syntaxhighlight>
<source lang='Python'>
<syntaxhighlight lang='Python'>
assert 1 == 2, 'Oh, my goodness.'
assert 1 == 2, 'Oh, my goodness.'
# AssertionError: Oh, my goodness.
# AssertionError: Oh, my goodness.
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[category: Perl]]
[[category: Perl]]
<source lang='Perl'>
<syntaxhighlight lang='Perl'>
die unless 1 eq 1;
die unless 1 eq 1;
die unless 1 eq 2;
die unless 1 eq 2;
# Died at - line 2
# Died at - line 2
</source>
</syntaxhighlight>
<source lang='Perl'>
<syntaxhighlight lang='Perl'>
die("Oh, my goodness.") unless 1 eq 2;
die("Oh, my goodness.") unless 1 eq 2;
# Oh, my goodness. at - line 1.
# Oh, my goodness. at - line 1.
</source>
</syntaxhighlight>
<syntaxhighlight lang='Perl'>
use Carp::Assert;
assert(1 eq 2);
</syntaxhighlight>

2020년 11월 2일 (월) 02:31 기준 최신판

assert
die

1 Python[ | ]

assert 1 == 1
assert 1 == 2
# AssertionError
assert 1 == 2, 'Oh, my goodness.'
# AssertionError: Oh, my goodness.

2 Perl[ | ]

die unless 1 eq 1;
die unless 1 eq 2;
# Died at - line 2
die("Oh, my goodness.") unless 1 eq 2;
# Oh, my goodness. at - line 1.
use Carp::Assert;
assert(1 eq 2);
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}