Ticket #1313: library_parrotlib_t.patch

File library_parrotlib_t.patch, 5.1 KB (added by bubaflub, 12 years ago)

patch to convert t/library/parrotlib.t to PIR

  • t/library/parrotlib.t

    diff --git t/library/parrotlib.t t/library/parrotlib.t
    index 50bb651..047d041 100644
     
    1 #!perl 
    2 # Copyright (C) 2001-2005, Parrot Foundation. 
     1#!parrot 
     2# Copyright (C) 2001-2009, Parrot Foundation. 
    33# $Id$ 
    44 
    5 use strict; 
    6 use warnings; 
    7 use lib qw( t . lib ../lib ../../lib ); 
    8 use Test::More; 
    9 use Parrot::Test tests => 6; 
    10 use Parrot::Config; 
    11  
    125=head1 NAME 
    136 
    147t/library/parrotlib.t - testing library/parrotlib.pir 
     
    2619 
    2720# Common code in the test files 
    2821 
    29 my $template_top = << 'END_CODE'; 
    30 .sub _main 
    31  
    32   load_bytecode 'runtime/parrot/include/parrotlib.pbc' 
    33   .local pmc    location_sub 
    34   .local string location 
    35 END_CODE 
    36  
    37 my $template_bottom = << 'END_CODE'; 
    38   print location 
    39   print "\n" 
    40  
    41   end 
     22.sub main :main 
     23    load_bytecode 'runtime/parrot/include/parrotlib.pbc' 
     24 
     25    .include 'test_more.pir' 
     26    plan(6) 
     27     
     28    test_include_file_location() 
     29    test_include_file_location_non_existent() 
     30    test_imcc_compile_file_location() 
     31    test_imcc_compile_file_location_non_existent() 
     32    test_dynext_location() 
     33    test_dynext_location_non_existent() 
    4234.end 
    43 END_CODE 
    4435 
    45 # Testing include_file_location 
    4636 
    47 pir_output_is( << "END_CODE", << 'END_OUT', 'include_file_location' ); 
    48 $template_top 
    49   location_sub = get_global ["_parrotlib"], "include_file_location" 
    50   location     = location_sub( 'datatypes.pasm' ) 
    51 $template_bottom 
    52 END_CODE 
    53 runtime/parrot/include/datatypes.pasm 
    54 END_OUT 
     37# Testing include_file_location 
    5538 
    56 pir_output_is( << "END_CODE", << 'END_OUT', 'include_file_location, non-existent' ); 
    57 $template_top 
    58   location_sub = get_global ['_parrotlib'], "include_file_location" 
    59   location     = location_sub( 'nonexistent.pasm' ) 
    60 $template_bottom 
    61 END_CODE 
     39.sub test_include_file_location 
     40    .local pmc    location_sub 
     41    .local string location 
     42    location_sub = get_global ["_parrotlib"], "include_file_location" 
     43    location     = location_sub( 'datatypes.pasm' ) 
     44    is(location,'runtime/parrot/include/datatypes.pasm', 'include file location' ) 
     45.end 
    6246 
    63 END_OUT 
     47.sub test_include_file_location_non_existent 
     48    .local pmc    location_sub 
     49    .local string location 
     50    location_sub = get_global ['_parrotlib'], "include_file_location" 
     51    location     = location_sub( 'nonexistent.pasm' ) 
     52    is(location, '', 'include file location non-existent') 
     53.end 
    6454 
    6555# Testing imcc_compile_file_location 
    6656 
    67 pir_output_is( << "END_CODE", << 'END_OUT', 'imcc_compile_file_location' ); 
    68 $template_top 
    69   location_sub = get_global ['_parrotlib'], "imcc_compile_file_location" 
    70   location     = location_sub( 'parrotlib.pbc' ) 
    71 $template_bottom 
    72 END_CODE 
    73 runtime/parrot/include/parrotlib.pbc 
    74 END_OUT 
    75  
    76 pir_output_is( << "END_CODE", << 'END_OUT', 'imcc_compile_file_location, non-existent' ); 
    77 $template_top 
    78   location_sub = get_global ['_parrotlib'], "imcc_compile_file_location" 
    79   location     = location_sub( 'nonexistent.pbc' ) 
    80 $template_bottom 
    81 END_CODE 
     57.sub test_imcc_compile_file_location 
     58    .local pmc    location_sub 
     59    .local string location 
     60    location_sub = get_global ['_parrotlib'], "imcc_compile_file_location" 
     61    location     = location_sub( 'parrotlib.pbc' ) 
     62    is(location, 'runtime/parrot/include/parrotlib.pbc','imcc compile file location') 
     63.end 
    8264 
    83 END_OUT 
     65.sub test_imcc_compile_file_location_non_existent 
     66    .local pmc    location_sub 
     67    .local string location 
     68    location_sub = get_global ['_parrotlib'], "imcc_compile_file_location" 
     69    location     = location_sub( 'nonexistent.pbc' ) 
     70    is(location, '', 'imcc compile file location, non-existent') 
     71.end 
    8472 
    8573# Testing dynext_location 
    8674 
    87 pir_output_is( << "END_CODE", << "END_OUT", 'dynext_location' ); 
    88 $template_top 
    89   location_sub = get_global ['_parrotlib'], "dynext_location" 
    90   location     = location_sub( 'libnci_test', '$PConfig{load_ext}' ) 
    91 $template_bottom 
    92 END_CODE 
    93 runtime/parrot/dynext/libnci_test$PConfig{load_ext} 
    94 END_OUT 
    95  
    96 pir_output_is( << "END_CODE", << 'END_OUT', 'dynext_location, non-existent' ); 
    97 $template_top 
    98   location_sub = get_global ['_parrotlib'], "imcc_compile_file_location" 
    99   location     = location_sub( 'nonexistent' ) 
    100 $template_bottom 
    101 END_CODE 
     75.sub test_dynext_location 
     76    .include 'iglobals.pasm' 
     77    .local pmc config_hash, interp 
     78    .local pmc    location_sub 
     79    .local string location 
     80 
     81    interp = getinterp 
     82    config_hash = interp[.IGLOBALS_CONFIG_HASH] 
     83    $S0 = config_hash['load_ext'] 
     84    location_sub = get_global ['_parrotlib'], "dynext_location" 
     85    location     = location_sub( 'libnci_test', $S0 ) 
     86    $S1 = 'runtime/parrot/dynext/libnci_test' 
     87    $S1 .= $S0 
     88    is(location, $S1, 'dynext_location') 
     89.end 
    10290 
    103 END_OUT 
     91.sub test_dynext_location_non_existent 
     92    .local pmc    location_sub 
     93    .local string location 
     94    location_sub = get_global ['_parrotlib'], "imcc_compile_file_location" 
     95    location     = location_sub( 'nonexistent' ) 
     96    is(location, '', 'dynext location non-existent') 
     97.end 
    10498 
    10599=head1 AUTHOR 
    106100 
     
    117111#   cperl-indent-level: 4 
    118112#   fill-column: 100 
    119113# End: 
    120 # vim: expandtab shiftwidth=4: 
     114# vim: expandtab shiftwidth=4 filetype=pir: