Ticket #1592: r45961.diff
| File r45961.diff, 3.3 KB (added by jkeenan, 3 years ago) |
|---|
-
src/io/api.c
122 122 ASSERT_ARGS(Parrot_io_open) 123 123 PMC *new_filehandle, *filehandle; 124 124 INTVAL flags; 125 const INTVAL typenum = Parrot_get_ctx_HLL_type(interp, Parrot_PMC_typenum(interp, "FileHandle")); 125 126 if (PMC_IS_NULL(pmc)) { 126 /* TODO: We should look up the HLL mapped type, instead of always 127 using FileHandle here */ 128 new_filehandle = Parrot_pmc_new(interp, enum_class_FileHandle); 129 PARROT_ASSERT(new_filehandle->vtable->base_type == enum_class_FileHandle); 127 new_filehandle = Parrot_pmc_new(interp, typenum); 128 PARROT_ASSERT(new_filehandle->vtable->base_type == typenum); 130 129 } 131 130 else 132 131 new_filehandle = pmc; 133 132 134 133 flags = Parrot_io_parse_open_flags(interp, mode); 135 if (new_filehandle->vtable->base_type == enum_class_FileHandle) {134 if (new_filehandle->vtable->base_type == typenum) { 136 135 /* TODO: StringHandle may have a null path, but a filehandle really 137 136 shouldn't allow that. */ 138 PARROT_ASSERT(new_filehandle->vtable->base_type == enum_class_FileHandle);137 PARROT_ASSERT(new_filehandle->vtable->base_type == typenum); 139 138 filehandle = PIO_OPEN(interp, new_filehandle, path, flags); 140 139 if (PMC_IS_NULL(filehandle)) 141 140 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR, 142 141 "Unable to open filehandle from path '%S'", path); 143 PARROT_ASSERT(filehandle->vtable->base_type == enum_class_FileHandle);142 PARROT_ASSERT(filehandle->vtable->base_type == typenum); 144 143 SETATTR_FileHandle_flags(interp, new_filehandle, flags); 145 144 SETATTR_FileHandle_filename(interp, new_filehandle, path); 146 145 SETATTR_FileHandle_mode(interp, new_filehandle, mode); -
t/op/io.t
16 16 17 17 =cut 18 18 19 .const int TESTS = 419 .const int TESTS = 5 20 20 21 21 .sub 'main' :main 22 22 .include 'test_more.pir' 23 23 24 24 plan(TESTS) 25 25 26 open_delegates_to_filehandle_pmc() 26 27 open_null_filename() 27 28 open_null_mode() 28 29 open_pipe_for_reading() 29 30 open_pipe_for_writing() 30 31 .end 31 32 33 .sub open_delegates_to_filehandle_pmc 34 load_bytecode 'P6object.pbc' 35 36 .local pmc p6meta, interp, classes, classid 37 p6meta = get_root_global ["parrot"], "P6metaclass" 38 p6meta.'new_class'('Testing') 39 40 interp = getinterp 41 classes = interp[0] 42 classid = classes['Testing'] 43 $I0 = classes['FileHandle'] 44 set classes['FileHandle'], classid 45 46 $P1 = open '/foo' 47 48 # replace the original, so we don't break other tests 49 set classes['FileHandle'], $I0 50 51 .end 52 32 53 .sub 'open_null_filename' 33 54 push_eh open_null_filename_failed 34 55 null $S0 … … 127 148 .local pmc pipe 128 149 pipe = open command, 'wp' 129 150 unless pipe goto open_pipe_for_writing_failed 130 pipe.'puts'("ok - open pipe for writing\n") 151 152 pipe.'puts'("ok 5 - open pipe for writing\n") 131 153 close pipe 132 154 .return () 133 155 … … 140 162 141 163 .end 142 164 165 .namespace ["Testing"] 166 167 .sub open :method 168 .param pmc args :slurpy 169 ok(1,'open opcode delegates to the FileHandle PMC') 170 .end 171 172 143 173 # Local Variables: 144 174 # mode: pir 145 175 # fill-column: 100
