diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-31 17:53:01 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-31 17:53:01 -0200 |
commit | b68fb7f62e1475e28a4cb27569e8b659f925e114 (patch) | |
tree | f6f68d64789b0970fbc2ec4dcc74de5ab9f23b13 | |
parent | 60ff79451c32e1e6dbec001846871aa878c43289 (diff) | |
download | lua-b68fb7f62e1475e28a4cb27569e8b659f925e114.tar.gz lua-b68fb7f62e1475e28a4cb27569e8b659f925e114.tar.bz2 lua-b68fb7f62e1475e28a4cb27569e8b659f925e114.zip |
`assert' returns its first argument
-rw-r--r-- | lbaselib.c | 5 | ||||
-rw-r--r-- | manual.tex | 8 |
2 files changed, 8 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.18 2001/01/10 16:58:11 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.19 2001/01/25 16:45:36 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -404,7 +404,8 @@ static int luaB_assert (lua_State *L) { | |||
404 | luaL_checkany(L, 1); | 404 | luaL_checkany(L, 1); |
405 | if (lua_isnil(L, 1)) | 405 | if (lua_isnil(L, 1)) |
406 | luaL_verror(L, "assertion failed! %.90s", luaL_opt_string(L, 2, "")); | 406 | luaL_verror(L, "assertion failed! %.90s", luaL_opt_string(L, 2, "")); |
407 | return 0; | 407 | lua_settop(L, 1); |
408 | return 1; | ||
408 | } | 409 | } |
409 | 410 | ||
410 | 411 | ||
@@ -1,4 +1,4 @@ | |||
1 | % $Id: manual.tex,v 1.47 2000/12/28 17:25:45 roberto Exp roberto $ | 1 | % $Id: manual.tex,v 1.48 2001/01/29 19:33:55 roberto Exp roberto $ |
2 | 2 | ||
3 | \documentclass[11pt]{article} | 3 | \documentclass[11pt]{article} |
4 | \usepackage{fullpage} | 4 | \usepackage{fullpage} |
@@ -134,7 +134,7 @@ Waldemar Celes | |||
134 | \tecgraf\ --- Computer Science Department --- PUC-Rio | 134 | \tecgraf\ --- Computer Science Department --- PUC-Rio |
135 | } | 135 | } |
136 | 136 | ||
137 | \date{{\small \tt\$Date: 2000/12/28 17:25:45 $ $}} | 137 | \date{{\small \tt\$Date: 2001/01/29 19:33:55 $ $}} |
138 | 138 | ||
139 | \maketitle | 139 | \maketitle |
140 | 140 | ||
@@ -2436,7 +2436,8 @@ to change the way such messages are shown | |||
2436 | 2436 | ||
2437 | \subsubsection*{\ff \T{assert (v [, message])}}\DefLIB{assert} | 2437 | \subsubsection*{\ff \T{assert (v [, message])}}\DefLIB{assert} |
2438 | Issues an \emph{``assertion failed!''} error | 2438 | Issues an \emph{``assertion failed!''} error |
2439 | when its argument \verb|v| is \nil. | 2439 | when its argument \verb|v| is \nil; |
2440 | otherwise, returns this argument. | ||
2440 | This function is equivalent to the following Lua function: | 2441 | This function is equivalent to the following Lua function: |
2441 | \begin{verbatim} | 2442 | \begin{verbatim} |
2442 | function assert (v, m) | 2443 | function assert (v, m) |
@@ -2444,6 +2445,7 @@ This function is equivalent to the following Lua function: | |||
2444 | m = m or "" | 2445 | m = m or "" |
2445 | error("assertion failed! " .. m) | 2446 | error("assertion failed! " .. m) |
2446 | end | 2447 | end |
2448 | return v | ||
2447 | end | 2449 | end |
2448 | \end{verbatim} | 2450 | \end{verbatim} |
2449 | 2451 | ||