⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 30_preproc.t

📁 Verilog Parser in Perl
💻 T
字号:
#!/usr/bin/perl -w# DESCRIPTION: Perl ExtUtils: Type 'make test' to test this package## Copyright 2000-2009 by Wilson Snyder.  This program is free software;# you can redistribute it and/or modify it under the terms of either the GNU# Lesser General Public License or the Perl Artistic License.use IO::File;use strict;use Test;BEGIN { plan tests => 12 }BEGIN { require "t/test_utils.pl"; }#######################################################################package MyPreproc;use Verilog::Preproc;use base qw(Verilog::Preproc);sub comment { print $::OUTTO "COMMENT: $_[1]\n";	      $_[0]->unreadback(' /*CMT*/ '); }package main;#######################################################################sub prep {    my $opt = new Verilog::Getopt;    $opt->parameter (qw(			+incdir+verilog			));    return $opt;}use Verilog::Getopt;ok(1);use Verilog::Preproc;ok(1);{    my $opt = prep();    my $pp = new Verilog::Preproc (options=>$opt);    ok(1);    #$pp->debug(9);    $pp->open("inc1.v");    $pp->open("inc2.v");    ok(1);    my $fhout = IO::File->new(">test_dir/inc.out");    my $ln = 1;    while (defined(my $line = $pp->getline())) {	#print "LINE: $line";	print $fhout $pp->filename.":".$pp->lineno.": ".$line;	die if ++$ln > 2000;    }    ok(1);    $fhout->close();    ok(files_identical("test_dir/inc.out", "t/30_preproc.out"));}test ('_sub', keep_comments=>'sub',);test ('_on',  keep_comments=>1,);test ('_nows', keep_comments=>0, keep_whitespace=>0,);sub test {    my $id = shift;    my @args = @_;    my $opt = prep();    my $pp = new MyPreproc (options=>$opt, @args);    $pp->open("inc1.v");    $pp->open("inc2.v");    $pp->open("inc_ifdef.v");    my $fhout = IO::File->new(">test_dir/inc${id}.out");    $::OUTTO = $fhout;    while (defined(my $line = $pp->getline())) {	print $fhout $pp->filename.":".$pp->lineno.": ".$line;    }    $fhout->close();    ok(1);    ok(files_identical("test_dir/inc${id}.out", "t/30_preproc${id}.out"));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -