Author: fperrad
Date: Mon Feb 20 00:00:49 2006
New Revision: 11675

Added:
   trunk/languages/lua/t/metatable.t
   trunk/languages/lua/t/os.t
Removed:
   trunk/languages/lua/t/lib/os.t
Modified:
   trunk/languages/lua/lib/luabasic.pir
   trunk/languages/lua/pmc/luaboolean.pmc
   trunk/languages/lua/pmc/luastring.pmc
   trunk/languages/lua/pmc/luatable.pmc
   trunk/languages/lua/pmc/luauserdata.pmc
   trunk/languages/lua/t/basic.t
   trunk/languages/lua/t/pmc/string.t
   trunk/languages/lua/t/pmc/table.t
   trunk/languages/lua/t/pmc/userdata.t
   trunk/languages/lua/t/tables.t
Log:
Lua :
- new implementation of LuaTable & LuaUserdata PMC
- basic library : add getmetatable & setmetatable
- and tests

Modified: trunk/languages/lua/lib/luabasic.pir
==============================================================================
--- trunk/languages/lua/lib/luabasic.pir        (original)
+++ trunk/languages/lua/lib/luabasic.pir        Mon Feb 20 00:00:49 2006
@@ -207,7 +207,7 @@ it defaults to "assertion failed!"
     .param pmc v :optional
     .param pmc message :optional
     checkany(v)
-    $I0 = v
+    $I0 = istrue v
     if $I0 goto L0
     $S0 = optstring(message, "assertion failed!")
     error($S0)
@@ -298,14 +298,24 @@ If the object does not have a metatable,
 object�s metatable has a C<"__metatable"> field, returns the associated value.
 Otherwise, returns the metatable of the given object.
 
-NOT YET IMPLEMENTED.
-
 =cut
 
 .sub _lua_getmetatable :anon
     .param pmc obj :optional
+    .local pmc ret
     checkany(obj)
-    not_implemented()
+    ret = getprop "__metatable", obj
+    if ret goto L1
+    new ret, .LuaNil
+    .return (ret)
+L1:
+    .local pmc prot
+    .const .LuaString mt = "__metatable"
+    prot = ret[mt]
+    unless prot goto L2
+    .return (prot)
+L2:
+    .return (ret)
 .end
 
 =item C<gcinfo ()>
@@ -573,7 +583,8 @@ C<table> must be a table; C<index> is an
     .local pmc ret
     checktype(table, "table")
     checkany(index)
-    ret = table[index]
+#    ret = table[index]
+     ret = table."rawget"(index)
     .return (ret)
 .end
 
@@ -592,7 +603,8 @@ B<nil>, and C<value> is any Lua value.
     checktype(table, "table")
     checkany(index)
     checkany(value)
-    table[index] = value
+#    table[index] = value
+    table."rawset"(index, value)
     .return ()
 .end
 
@@ -671,8 +683,6 @@ a userdata from Lua.) If metatable is B<
 given table. If the original metatable has a C<"__metatable"> field, raises
 an error.
 
-NOT YET IMPLEMENTED.
-
 =cut
 
 .sub _lua_setmetatable :anon
@@ -685,8 +695,22 @@ NOT YET IMPLEMENTED.
     if $S0 == "table" goto L1
 L0:
     argerror("nil or table expected")
-L1:    
-    not_implemented()
+L1:
+    .local pmc meta
+    meta = getprop "__metatable", table
+    unless meta goto L3
+    .local pmc prot
+    .const .LuaString mt = "__metatable"
+    prot = meta[mt]
+    unless prot goto L3
+    error("cannot change a protected metatable")
+L3:
+    if $S0 == "table" goto L4
+    delprop table, "__metatable"
+    .return ()
+L4:    
+    setprop table, "__metatable", metatable
+    .return ()
 .end
 
 =item C<tonumber (e [, base])>

Modified: trunk/languages/lua/pmc/luaboolean.pmc
==============================================================================
--- trunk/languages/lua/pmc/luaboolean.pmc      (original)
+++ trunk/languages/lua/pmc/luaboolean.pmc      Mon Feb 20 00:00:49 2006
@@ -184,7 +184,7 @@ Used to archive the boolean.

     void freeze (visit_info *info) {

         IMAGE_IO *io = info->image_io;

         SUPER(info);

-        io->vtable->push_integer(INTERP, io, PMC_int_val(SELF));

+        VTABLE_push_integer(INTERP, io, PMC_int_val(SELF));

     }

 

 /*

@@ -200,7 +200,7 @@ Used to unarchive the boolean.

         IMAGE_IO *io = info->image_io;

         SUPER(info);

         if (info->extra_flags == EXTRA_IS_NULL)

-            PMC_int_val(SELF) = io->vtable->shift_integer(INTERP, io);

+            PMC_int_val(SELF) = VTABLE_shift_integer(INTERP, io);

     }

 

 /*


Modified: trunk/languages/lua/pmc/luastring.pmc
==============================================================================
--- trunk/languages/lua/pmc/luastring.pmc       (original)
+++ trunk/languages/lua/pmc/luastring.pmc       Mon Feb 20 00:00:49 2006
@@ -266,7 +266,7 @@ Used to archive the string.

     void freeze(visit_info *info) {

         IMAGE_IO *io = info->image_io;

         SUPER(info);

-        io->vtable->push_string(INTERP, io, PMC_str_val(SELF));

+        VTABLE_push_string(INTERP, io, PMC_str_val(SELF));

     }

 

 /*

@@ -282,7 +282,7 @@ Used to unarchive the string.

         IMAGE_IO *io = info->image_io;

         SUPER(info);

         if (info->extra_flags == EXTRA_IS_NULL)

-            PMC_str_val(SELF) = io->vtable->shift_string(INTERP, io);

+            PMC_str_val(SELF) = VTABLE_shift_string(INTERP, io);

     }

 

 /*

@@ -827,20 +827,6 @@ MMD_DEFAULT: {

         return retval;

     }

 

-/*

-

-=item C<PMC* tostring()>

-

-=cut

-

-*/

-    METHOD PMC* tostring() {

-        PMC *retval;

-

-        retval = VTABLE_clone(INTERP, SELF); 

-        return retval;

-    }

-

 }

 

 /*


Modified: trunk/languages/lua/pmc/luatable.pmc
==============================================================================
--- trunk/languages/lua/pmc/luatable.pmc        (original)
+++ trunk/languages/lua/pmc/luatable.pmc        Mon Feb 20 00:00:49 2006
@@ -4,11 +4,11 @@ $Id$

 

 =head1 NAME

 

-classes/luatable.pmc - Lua Table

+pmc/luatable.pmc - Lua Table

 

 =head1 DESCRIPTION

 

-C<LuaTable> extends C<Hash> to provide a class with the behaviour of

+C<LuaTable> extends C<LuaBase> to provide a class with the behaviour of

 the Lua C<Table> type.

 

 TRIVIAL IMPLEMENTATION : C<Table> is just a Parrot C<Hash>, like in Lua 4.0.

@@ -28,8 +28,21 @@ static STRING *luatable_name;

 static INTVAL dynpmc_LuaNil;

 static INTVAL dynpmc_LuaString;

 

+static STRING* make_hash_key(Interp* interpreter, PMC* key)

+{

+    if (key == NULL) {

+        real_exception(interpreter, NULL, E_KeyError,

+                "LuaTable: Cannot use NULL key");

+        return NULL;

+    }

+    return string_concat(interpreter, 

+            VTABLE_name(interpreter, key),

+            VTABLE_get_string(interpreter, key), 0);

+}

+

+

 pmclass LuaTable

-    extends Hash

+    extends LuaBase

     does hash

     dynpmc

     group lua_group

@@ -62,32 +75,79 @@ pmclass LuaTable

                 const_string(INTERP, "table"),

                 const_string(INTERP, "tonumber"),

                 meth);

+            meth = Parrot_find_global(INTERP,

+                const_string(INTERP, "LuaTable"),

+                const_string(INTERP, "rawget"));

+            Parrot_store_global(INTERP,

+                const_string(INTERP, "table"),

+                const_string(INTERP, "rawget"),

+                meth);

+            meth = Parrot_find_global(INTERP,

+                const_string(INTERP, "LuaTable"),

+                const_string(INTERP, "rawset"));

+            Parrot_store_global(INTERP,

+                const_string(INTERP, "table"),

+                const_string(INTERP, "rawset"),

+                meth);

         }

     }

 

 /*

 

-=item C<STRING* name()>

+=item C<void init()>

 

-Return the string "table".

+Initializes the instance.

 

 =cut

 

 */

-    STRING* name () {

-        return luatable_name;

+    void init () {

+        PMC_struct_val(SELF) = NULL;

+        PObj_custom_mark_destroy_SETALL(SELF);

+        new_pmc_hash(INTERP, SELF);

     }

 

+/*

+

+=item C<void mark()>

+

+Marks the hash as live.

+

+=cut

+

+*/

+    void mark () {

+        if (PMC_struct_val(SELF))

+            mark_hash(INTERP, PMC_struct_val(SELF));

+    }

 

 /*

 

-=item C<STRING* get_string()>

+=item C<void destroy()>

+

+Free hash structure.

 

 =cut

 

 */

-    STRING* get_string () {

-        return Parrot_sprintf_c(INTERP, "table: %08X", SELF);

+    void destroy () {

+        if (PMC_struct_val(SELF)) {

+            hash_destroy(INTERP, (Hash*) PMC_struct_val(SELF));

+            PMC_struct_val(SELF) = NULL;

+        }

+    }

+

+/*

+

+=item C<STRING* name()>

+

+Return the string "table".

+

+=cut

+

+*/

+    STRING* name () {

+        return luatable_name;

     }

 

 /*

@@ -111,18 +171,13 @@ only clone the reference to themselves, 
 

 /*

 

-=item C<INTVAL get_bool()>

-

-In Lua, both C<nil> and C<false> make a condition false; any other values

-makes it true.

-

-So return always true.

+=item C<STRING* get_string()>

 

 =cut

 

 */

-    INTVAL get_bool () {

-        return 1;

+    STRING* get_string () {

+        return Parrot_sprintf_c(INTERP, "table: %08X", SELF);

     }

 

 /*

@@ -142,14 +197,19 @@ A copy of the value is retrieved, otherw
 

 */

     PMC* get_pmc_keyed (PMC* key) {

+        Hash *hash;

+        STRING *keystr;

+        PMC *retval;

         PMC *newcopy;

-        PMC *retval = SUPER(key);

 

-        if (enum_class_None == retval->vtable->base_type) {

+        hash = PMC_struct_val(SELF);

+        keystr = make_hash_key(INTERP, key);

+        retval = hash_get(INTERP, PMC_struct_val(SELF), keystr);

+        if (retval == NULL) {

             retval = pmc_new(INTERP, dynpmc_LuaNil);

             return retval;

         }

-        newcopy = retval->vtable->clone(INTERP, retval);

+        newcopy = VTABLE_clone(INTERP, retval);

         return newcopy;

     }

 

@@ -170,37 +230,44 @@ A copy of the value is stored, otherwise
 

 */

     void set_pmc_keyed (PMC* key, PMC* value) {

+        Hash *hash;

+        STRING *keystr;

+

         if (dynpmc_LuaNil == key->vtable->base_type) {

             real_exception(INTERP, NULL, 1, "table index is nil");

         }

+        hash = PMC_struct_val(SELF);

+        keystr = make_hash_key(INTERP, key);

         if (dynpmc_LuaNil == value->vtable->base_type) {

-            Hash.SELF.delete_keyed(key);

+            hash_delete(INTERP, hash, keystr);

         } 

         else {

-            PMC *newcopy = value->vtable->clone(INTERP, value);

-            SUPER(key, newcopy);

+            PMC *newcopy = VTABLE_clone(INTERP, value);

+            hash_put(INTERP, hash, keystr, newcopy);

         }

     }

 

 /*

 

-=item C<PMC logical_not(PMC *dest)>

+=item C<INTVAL elements()>

 

-Return always false.

+Returns the number of elements in the hash.

 

 =cut

 

 */

-    PMC* logical_not (PMC* dest) {

-        if (!dest)

-            dest = pmc_new(INTERP, pmc_type(INTERP,

-              string_from_const_cstring(INTERP, "LuaBoolean", 0)));

-        VTABLE_set_integer_native(INTERP, dest, 0);

-        return dest;

+    INTVAL elements () {

+        return hash_size(INTERP, PMC_struct_val(SELF));

     }

 

 /*

 

+=back

+

+=head2 non-Vtable Methods

+

+=over 4

+

 =item C<INTVAL is_equal (PMC* value)>

 

 The C<==> operation. Compares reference (not in depth).

@@ -215,54 +282,25 @@ The C<==> operation. Compares reference 
             return (INTVAL)0;

     }

 

-    /* Other metamethods */

-

-    PMC* add (PMC* value, PMC* dest) {

-        PMC *metatable = DYNSELF.getprop("__metatable");

-        if (metatable) {

-            printf("found metatable\n");

-        } else {

-            printf("Failed to find a metatable\n");

-        }

-        return (PMC*)0;

-    }

-

-    /* TODO: Implement the Metamethod mechanism, see the Lua ref.man. */

-

-    PMC* subtract (PMC* value, PMC* dest) {

-        return (PMC*)0;

-    }

-

-    PMC* multiply (PMC* value, PMC* dest) {

-        return (PMC*)0;

-    }

-

-    PMC* divide (PMC* value, PMC* dest) {

-        return (PMC*)0;

-    }

-

-    PMC* modulus (PMC* value, PMC* dest) {

-        return (PMC*)0;

-    }

-

-    PMC* pow (PMC* value, PMC* dest) {

-        return (PMC*)0;

-    }

-

-    PMC* neg (PMC* dest) {

-        return (PMC*)0;

-    }

+/*

 

-    PMC* concatenate (PMC* value, PMC* dest) {

-        return (PMC*)0;

-    }

+=item C<INTVAL cmp (PMC *value)>

 

-    void* invoke (void* next) {

-        return (void*)0;

-    }

+=cut

 

+*/

     INTVAL cmp (PMC* value) {

-        return (INTVAL)0;

+MMD_LuaTable: {

+            real_exception(INTERP, NULL, ILL_INHERIT,

+                    "attempt to compare two table values");

+            return (INTVAL)0;

+        }

+MMD_DEFAULT: {

+            real_exception(INTERP, NULL, ILL_INHERIT,

+                    "attempt to compare table with %s",

+                    string_to_cstring(INTERP, VTABLE_name(INTERP, value)));

+            return (INTVAL)0;

+        }

     }

 

 /*

@@ -273,38 +311,54 @@ The C<==> operation. Compares reference 
 

 =over 4

 

-=item C<PMC* tonumber()>

+=item C<PMC* rawget (PMC* key)>

 

 =cut

 

 */

-    METHOD PMC* tonumber() {

+    METHOD PMC* rawget (PMC* key) {

+        Hash *hash;

+        STRING *keystr;

         PMC *retval;

+        PMC *newcopy;

 

-        retval = pmc_new(INTERP, dynpmc_LuaNil);

-        return retval;

+        hash = PMC_struct_val(SELF);

+        keystr = make_hash_key(INTERP, key);

+        retval = hash_get(INTERP, PMC_struct_val(SELF), keystr);

+        if (retval == NULL) {

+            retval = pmc_new(INTERP, dynpmc_LuaNil);

+            return retval;

+        }

+        newcopy = VTABLE_clone(INTERP, retval);

+        return newcopy;

     }

 

 /*

 

-=item C<PMC* tostring()>

+=item C<void rawset (PMC* key, PMC* value)>

 

 =cut

 

 */

-    METHOD PMC* tostring() {

-        PMC *retval;

-        STRING *rep;

+    METHOD void rawset (PMC* key, PMC* value) {

+        Hash *hash;

+        STRING *keystr;

 

-        /* TODO: __tostring */

-        retval = pmc_new(INTERP, dynpmc_LuaString);

-        rep = VTABLE_get_string(INTERP, SELF);

-        PMC_str_val(retval) = rep;

-        return retval;

+        if (dynpmc_LuaNil == key->vtable->base_type) {

+            real_exception(INTERP, NULL, 1, "table index is nil");

+        }

+        hash = PMC_struct_val(SELF);

+        keystr = make_hash_key(INTERP, key);

+        if (dynpmc_LuaNil == value->vtable->base_type) {

+            hash_delete(INTERP, hash, keystr);

+        } 

+        else {

+            PMC *newcopy = VTABLE_clone(INTERP, value);

+            hash_put(INTERP, hash, keystr, newcopy);

+        }

     }

 

 }

-

 /*

 

 =back


Modified: trunk/languages/lua/pmc/luauserdata.pmc
==============================================================================
--- trunk/languages/lua/pmc/luauserdata.pmc     (original)
+++ trunk/languages/lua/pmc/luauserdata.pmc     Mon Feb 20 00:00:49 2006
@@ -8,7 +8,7 @@ classes/luauserdata.pmc - Lua Userdata

 

 =head1 DESCRIPTION

 

-C<LuaUserdata> extends C<String> to provide a class with the behaviour of

+C<LuaUserdata> extends C<LuaBase> to provide a class with the behaviour of

 the Lua C<Userdata> type.

 

 =head2 Overloaded Methods

@@ -22,12 +22,12 @@ the Lua C<Userdata> type.

 #include "parrot/parrot.h"

 

 static STRING *luauserdata_name;

-static INTVAL dynpmc_LuaNil;

 static INTVAL dynpmc_LuaString;

 

 

 pmclass LuaUserdata 

-    extends String

+    extends LuaBase

+    does scalar

     dynpmc 

     group lua_group 

     hll Lua {

@@ -39,8 +39,6 @@ pmclass LuaUserdata 

             PMC *meth;

 

             luauserdata_name = const_string(INTERP, "userdata");

-            dynpmc_LuaNil = pmc_type(INTERP,

-              string_from_const_cstring(INTERP, "LuaNil", 0));

             dynpmc_LuaString = pmc_type(INTERP,

               string_from_const_cstring(INTERP, "LuaString", 0));

 

@@ -64,80 +62,84 @@ pmclass LuaUserdata 

 

 /*

 

-=item C<STRING* name()>

+=item C<void init()>

 

-Return the string "userdata".

+Initializes the string.

 

 =cut

 

 */

-    STRING* name () {

-        return luauserdata_name;

+    void init () {

+        PMC_str_val(SELF) =

+            string_make_empty(INTERP, enum_stringrep_one, 0);

+        PObj_custom_mark_SET(SELF);

     }

 

 /*

 

-=item C<STRING* get_string()>

+=item C<void mark()>

+

+Marks the string as live.

 

 =cut

 

 */

-    STRING* get_string () {

-        return Parrot_sprintf_c(INTERP, "userdata: %08X", SELF);

+    void mark () {

+        if(PMC_str_val(SELF))

+            pobject_lives(INTERP, (PObj *)PMC_str_val(SELF));

     }

 

 /*

 

-=item C<INTVAL get_bool()>

-

-In Lua, both C<nil> and C<false> make a condition false; any other values 

-makes it true.

+=item C<PMC* clone()>

 

-So return always true. 

+Creates a copy of the string.

 

 =cut

 

 */

-    INTVAL get_bool () {

-        return 1;

+    PMC* clone () {

+        PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);

+        PObj_custom_mark_SET(dest);

+        PMC_str_val(dest) = string_copy(INTERP,PMC_str_val(SELF));

+        return dest;

     }

 

 /*

 

-=back

+=item C<STRING* get_string()>

 

-=head2 Specific Methods

+=cut

 

-=over 4

+*/

+    STRING* get_string () {

+        return Parrot_sprintf_c(INTERP, "userdata: %08X", SELF);

+    }

 

-=item C<PMC* tonumber()>

+/*

+

+=item C<STRING* name()>

+

+Return the string "userdata".

 

 =cut

 

 */

-    METHOD PMC* tonumber() {

-        PMC *retval;

-

-        retval = pmc_new(INTERP, dynpmc_LuaNil);

-        return retval;

+    STRING* name () {

+        return luauserdata_name;

     }

 

 /*

 

-=item C<PMC* tostring()>

+=item C<VOID set_string_native(STRING* value)>

+

+Sets the value of the string to that of the specified C<string>.

 

 =cut

 

 */

-    METHOD PMC* tostring() {

-        PMC *retval;

-        STRING *rep;

-

-        /* TODO: __tostring */

-        retval = pmc_new(INTERP, dynpmc_LuaString);

-        rep = VTABLE_get_string(INTERP, SELF);

-        PMC_str_val(retval) = rep;

-        return retval;

+    void set_string_native (STRING* value) {

+        PMC_str_val(SELF) = value;

     }

 

 }


Modified: trunk/languages/lua/t/basic.t
==============================================================================
--- trunk/languages/lua/t/basic.t       (original)
+++ trunk/languages/lua/t/basic.t       Mon Feb 20 00:00:49 2006
@@ -25,6 +25,8 @@ use Parrot::Test tests => 20;

 use Test::More;

 

 language_output_like( 'lua', << 'CODE', << 'OUTPUT', "function assert(false, 
msg)");

+assert("text", "assert string")

+assert({}, "assert table")

 assert(false, "ASSERTION TEST")

 CODE

 /ASSERTION TEST/


Added: trunk/languages/lua/t/metatable.t
==============================================================================
--- (empty file)
+++ trunk/languages/lua/t/metatable.t   Mon Feb 20 00:00:49 2006
@@ -0,0 +1,48 @@
+#! perl -w

+# Copyright: 2006 The Perl Foundation.  All Rights Reserved.

+# $Id: metatable.t 11501 2006-02-10 18:27:13Z particle $

+

+=head1 NAME

+

+t/metatable.t - Lua tables

+

+=head1 SYNOPSIS

+

+    % perl -I../lib -Ilua/t lua/t/metatable.t

+

+=head1 DESCRIPTION

+

+See "Programming in Lua", section 13 "Metatables and Metamethods".

+

+=cut

+

+use strict;

+use FindBin;

+use lib "$FindBin::Bin";

+

+use Parrot::Test tests => 2;

+use Test::More;

+

+language_output_is( 'lua', <<'CODE', <<'OUT', 'metatable' );

+t = {}

+print(getmetatable(t))

+t1 = {}

+setmetatable(t, t1)

+assert(getmetatable(t) == t1)

+CODE

+nil

+OUT

+

+

+language_output_like( 'lua', <<'CODE', <<'OUT', 'protected metatable' );

+t = {}

+mt = {}

+mt.__metatable = "not your business"

+setmetatable(t, mt)

+assert(getmetatable(t) == "not your business")

+setmetatable(t, {})

+CODE

+/cannot change a protected metatable/

+OUT

+

+


Added: trunk/languages/lua/t/os.t
==============================================================================
--- (empty file)
+++ trunk/languages/lua/t/os.t  Mon Feb 20 00:00:49 2006
@@ -0,0 +1,115 @@
+#! perl -w

+# Copyright: 2006 The Perl Foundation.  All Rights Reserved.

+# $Id: os.t 11478 2006-02-09 08:26:19Z fperrad $

+

+=head1 NAME

+

+t/os.t - Lua Operating System Library

+

+=head1 SYNOPSIS

+

+    % perl -I../lib -Ilua/t lua/t/os.t

+

+=head1 DESCRIPTION

+

+Tests Lua Operating System Library

+(implemented in F<languages/lua/lib/luaos.pir>).

+

+=cut

+

+use strict;

+use FindBin;

+use lib "$FindBin::Bin";

+

+use Parrot::Test tests => 12;

+use Test::More;

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function execute");

+cmd = "perl -e \"print 'test'; exit(2)\""

+r = os.execute(cmd)

+print(r)

+CODE

+test2

+OUTPUT

+

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function exit");

+print("reached")

+os.exit()

+print("not reached")

+CODE

+reached

+OUTPUT

+

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function getenv");

+print(os.getenv("PARROT_TMP"))

+CODE

+nil

+OUTPUT

+

+$ENV{PARROT_TMP} = "GETENV_PARROT";

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function getenv");

+print(os.getenv("PARROT_TMP"))

+CODE

+GETENV_PARROT

+OUTPUT

+

+

+open X, "> ../file.rm";

+print X "file to remove";

+close X;

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function remove");

+r = os.remove("file.rm")

+print(r)

+CODE

+true

+OUTPUT

+

+ok(!-e "../file.rm", "Test that the file is removed");

+unlink("../file.rm") if (-e "../file.rm");

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function remove");

+r, msg = os.remove("file.rm")

+print(r)

+print(msg)

+CODE

+nil

+file.rm: No such file or directory

+OUTPUT

+

+

+open X, "> ../file.old";

+print X "file to rename";

+close X;

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function rename");

+r = os.rename("file.old", "file.new")

+print(r)

+CODE

+true

+OUTPUT

+

+ok(!-e "../file.old", "Test that old file is missing");

+ok(-e "../file.new", "Test that new file is here");

+unlink("../file.old") if (-e "../file.old");

+unlink("../file.new") if (-e "../file.new");

+

+language_output_is( 'lua', << 'CODE', << 'OUTPUT', "function rename");

+r, msg = os.rename("file.old", "file.new")

+print(r)

+print(msg)

+CODE

+nil

+file.old: No such file or directory

+OUTPUT

+

+

+language_output_like( 'lua', << 'CODE', << 'OUTPUT', "function time");

+print(os.time())

+CODE

+/\d+/

+OUTPUT

+


Modified: trunk/languages/lua/t/pmc/string.t
==============================================================================
--- trunk/languages/lua/t/pmc/string.t  (original)
+++ trunk/languages/lua/t/pmc/string.t  Mon Feb 20 00:00:49 2006
@@ -30,9 +30,6 @@ pir_output_is(<< 'CODE', << 'OUTPUT', "c
     bool1 = isa pmc1, "LuaBase"

     print bool1

     print "\n"

-#    bool1 = isa pmc1, "String"

-#    print bool1

-#    print "\n"

     bool1 = isa pmc1, "LuaString"

     print bool1

     print "\n"


Modified: trunk/languages/lua/t/pmc/table.t
==============================================================================
--- trunk/languages/lua/t/pmc/table.t   (original)
+++ trunk/languages/lua/t/pmc/table.t   Mon Feb 20 00:00:49 2006
@@ -1,5 +1,5 @@
 #! perl -w

-# Copyright: 2005 The Perl Foundation.  All Rights Reserved.

+# Copyright: 2005-2006 The Perl Foundation.  All Rights Reserved.

 # $Id$

 

 =head1 NAME

@@ -30,7 +30,7 @@ pir_output_is(<< 'CODE', << 'OUTPUT', "c
     bool1 = isa pmc1, "scalar"

     print bool1

     print "\n"

-    bool1 = isa pmc1, "Hash"

+    bool1 = isa pmc1, "LuaBase"

     print bool1

     print "\n"

     bool1 = isa pmc1, "LuaTable"

@@ -90,7 +90,6 @@ pir_output_like(<< 'CODE', << 'OUTPUT', 
     find_type $I0, "LuaTable"

     .local pmc pmc1

     pmc1 = new $I0

-    pmc1["key"] = "value"

     print pmc1

     print "\n"

     end

@@ -109,7 +108,6 @@ pir_output_is(<< 'CODE', << 'OUTPUT', "c
     bool1 = istrue pmc1

     print bool1

     print "\n"

-    pmc1["key"] = "value"

     bool1 = istrue pmc1

     print bool1

     print "\n"


Modified: trunk/languages/lua/t/pmc/userdata.t
==============================================================================
--- trunk/languages/lua/t/pmc/userdata.t        (original)
+++ trunk/languages/lua/t/pmc/userdata.t        Mon Feb 20 00:00:49 2006
@@ -27,10 +27,7 @@ pir_output_is(<< 'CODE', << 'OUTPUT', "c
     .local pmc pmc1

     pmc1 = new $I0

     .local int bool1

-    bool1 = isa pmc1, "scalar"

-    print bool1

-    print "\n"

-    bool1 = isa pmc1, "String"

+    bool1 = isa pmc1, "LuaBase"

     print bool1

     print "\n"

     bool1 = isa pmc1, "LuaUserdata"

@@ -41,7 +38,6 @@ pir_output_is(<< 'CODE', << 'OUTPUT', "c
 CODE

 1

 1

-1

 OUTPUT

 

 pir_output_is(<< 'CODE', << 'OUTPUT', "check interface");


Modified: trunk/languages/lua/t/tables.t
==============================================================================
--- trunk/languages/lua/t/tables.t      (original)
+++ trunk/languages/lua/t/tables.t      Mon Feb 20 00:00:49 2006
@@ -79,9 +79,6 @@ nil

 10

 OUT

 

-TODO: {

-local $TODO = "discrimines type of key";

-

 language_output_is( 'lua', <<'CODE', <<'OUT', '' );

 i = 10; j = "10"; k = "+10"

 a = {}

@@ -98,7 +95,6 @@ yet another value

 one value

 one value

 OUT

-}

 

 language_output_is( 'lua', <<'CODE', <<'OUT', '' );

 t = { {"a","b","c"}, 10 }

Reply via email to