Update with current status
[gnash.git] / extensions / fileio / test.as
blob770b623aa4a0f1218ad6a3ef03785792f2dd344b
1 //
2 // Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software
3 // Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "dejagnu.as"
22 file = new FileIO();
24 // test stdio first
26 buf = "Hello World!\n";
27 fname = "/tmp/gnash_fileio_ext_test";
29 if (file.fopen(fname, "w+")) {
30 pass("FileIO::open()");
31 } else {
32 fail("FileIO::open()");
35 if (file.fputs(buf)) {
36 pass("FileIO::fputs()");
37 } else {
38 fail("FileIO::fputs()");
41 file.fwrite(buf, 12);
43 xxx = file.ftell();
44 if (file.fseek(0) == 0) {
45 pass("FileIO::fseek()");
46 } else {
47 fail("FileIO::fseek()");
50 if (file.fflush() == 0) {
51 pass("FileIO::fflush()");
52 } else {
53 fail("FileIO::fflush()");
56 if ((xxx > 0) && (file.ftell() == 0)) {
57 pass("FileIO::ftell()");
58 } else {
59 fail("FileIO::ftell()");
62 x = file.fgetc();
63 if (x == "H") {
64 pass("FileIO::fgetc()");
65 } else {
66 fail("FileIO::fgetc()");
68 //trace(x);
70 y = file.fgets();
71 if (y == "ello World!\n") {
72 pass("FileIO::fgets()");
73 } else {
74 fail("FileIO::fgets()");
77 file.close();
78 //trace(y);
80 //file.read(buf, count);
82 // These tests use standard I/O
83 if (file.putchar('X')) {
84 pass("FileIO::putchar()");
85 } else {
86 fail("FileIO::putchar()");
89 if (file.puts(buf)) {
90 pass("FileIO::puts()");
91 } else {
92 fail("FileIO::puts()");
96 // We can't test thigns automatically if we need user input, so thes
97 // are commented out.
99 // a = file.getchar();
100 // if (a) {
101 // pass("FileIO::getchar()");
102 // } else {
103 // fail("FileIO::getchar()");
104 // }
105 // trace(a);
107 // b = file.gets();
108 // if (b) {
109 // pass("FileIO::gets()");
110 // } else {
111 // fail("FileIO::gets()");
112 // }
113 //trace(b);
115 var ret = file.unlink(fname);
116 if ( true === ret ) {
117 pass("FileIO::unlink()");
118 } else {
119 fail("FileIO::unlink(" + fname + ") returned " + ret);
122 totals();