3分くらいで分かるassert()
Upcoming SlideShare
Loading in...5
×
 

3分くらいで分かるassert()

on

  • 2,511 views

2007/11/21 PHP懇親会

2007/11/21 PHP懇親会
http://d.hatena.ne.jp/i_ogi/20071122/1195763577

Statistics

Views

Total Views
2,511
Views on SlideShare
2,451
Embed Views
60

Actions

Likes
0
Downloads
9
Comments
0

1 Embed 60

http://d.hatena.ne.jp 60

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

3分くらいで分かるassert() 3分くらいで分かるassert() Presentation Transcript

  •  Z Z^ ,88079 KWWSSKSQHWDVVHUW
  • AA y Z^ = y _ `a ] yGKDWHQDQHMSLBRJL
  • ,88079 ^
  • ,88079 Z Z[ ERRO DVVHUW PL[HG DVVHUWLRQ y2 [DVVHUWLRQ =A Z )$/6( ] = y =_c [ = c ! [ = B Z [ tLQL _ Z DVVHUWBRSWLRQV
  • ,88079 Z Z[ y _c y 3+38QLW DVVHUW7UXH Z =7UXH ^ Z a [^ ycc ` = DVVHUWDFWLYH 2II ^
  • ,88079 Z Z[ function hoge($max) { // 0 $max $ret = mt_rand(0, $max): * // 0 $max assert(0 <= $ret && $ret <= $max); * return $ret; }
  • ,88079 Z Z[ function hoge($max) { // 0 $max $ret = mt_rand(0, $max); * // 0 $max assert('0 <= $ret && $ret <= $max'); * return $ret;  }
  • 29*7,3/ >LQW PLQ LQW PD[@ y ] PWBUDQG   Z= PLQ ! PD[[  ^ y  Z [ hoge(-10); Warning: assert(): Assertion quot;0 <= $ret && $ret <= $maxquot; failed in test.php on line 7
  • ,88079  y HYDO y  []] t Z ^ y ^= ZHYDO
  • ,88079 1) PHP_FUNCTION(assert) { zval **assertion; int val; char *myeval = NULL; char *compiled_string_description; if (! ASSERTG(active)) { RETURN_TRUE; c Z_ } #709:73 if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &assertion) == F WRONG_PARAM_COUNT; }
  • ] = ^ Q ! + y W []] = B `a ^Z  ^ y&1) ^Z = 3+3  ][ Z
  • y ! `aZ ^ y HYDO Y y& c][ !  [
  • 6Z ^ Z S
  • Z ] [