小编mad*_*dia的帖子

存根并模拟 Perl 中单元测试的子程序

我正在尝试对该模块进行单元测试。我需要帮助和信息,如何模拟或存根子例程来测试包。

我不想使用我在cpan 上遇到的模块。

perl mocking stub

2
推荐指数
1
解决办法
707
查看次数

#1136 - mysql 存储过程的列计数与第 1 行的值计数不匹配

当我尝试调用以下 sp 代码时,它给出了上述错误。参数数量相等

drop procedure if exists add_post_with_name;
create procedure add_post_with_name(  in_author_name int ,in_title varchar(150),in_content text , in_html text, in_slug varchar(250),in_post_type varchar(50) , in_url tinyint)  
begin
    declare post_id int default 0;
    declare author_id int default 0;

    select id into author_id from user_profile where user_name = in_author_name;
    if ( author_id ) then
      insert into post (title,content,html,slug,post_type,url,author_id)
              values (in_title,in_content,in_html,in_slug,in_post_type,in_url);
      select id into post_id from post where id = last_insert_id();

      if ( in_post_type = 'SCHOLARSHIP' or in_post_type = 'JOB'
          or in_post_type = 'QUESTION' …
Run Code Online (Sandbox Code Playgroud)

mysql stored-procedures

2
推荐指数
1
解决办法
2650
查看次数

重载标准Tcl命令

小查询相关的程序范围

proc lappend {args} {
   set a $args
   lappend a testing ;# want to call the inbuilt tcl lappend command
   puts "$a"
}

set list {new to tcl}
lappend $list
Run Code Online (Sandbox Code Playgroud)

tcl

1
推荐指数
1
解决办法
1078
查看次数

期望TCL中的错误用于非初始化变量的代码

我有下面的小代码我期待TCL解释器为未初始化的变量抛出错误但它没有抛出错误

set v1 "test" 
if { ($v1 != "test") && ($v2 == "3") } { 
  puts "fun" 
} 
#v2 is not initialized   
Run Code Online (Sandbox Code Playgroud)

解释器没有为v2抛出错误,因为它没有初始化

tcl

1
推荐指数
1
解决办法
137
查看次数

perl中符号引用与硬引用的区别

我一直在使用perl中的硬引用.但是想到符号引用可以对程序员有什么帮助.

           no strict "ref";
Run Code Online (Sandbox Code Playgroud)

perl use-strict

1
推荐指数
1
解决办法
561
查看次数

perl表达式对语句$ a && =;的含义

最近我在博客上遇到了这个Perl表达,无法抓住它的目的.

    my $success = 1; 
    $success &&= $insert_handle->execute($first, $last, $department); 
    $success &&= $update_handle->execute($department);
Run Code Online (Sandbox Code Playgroud)

perl

0
推荐指数
1
解决办法
348
查看次数

无法在perl中返回object属性的默认值

我有一个模块,当我试图在初始化中设置默认属性时,在调用子例程时给出以下错误 get_name

     Use of uninitialized value
Run Code Online (Sandbox Code Playgroud)

示例代码

     package test;
     #....
     #....
     sub new {
         my ($class) =  @_;
         my $self    = {};
         bless $self,$class;
         $self->_initialize();
         return $self;
     }

     sub _initailalize {
        my($self) = @_;
        $self = {
                     _name => 'NA'
        };
     }

     sub get_name {
              return $_[0]->{_name};
     }
Run Code Online (Sandbox Code Playgroud)

需要宝贵的投入.

oop perl

0
推荐指数
1
解决办法
89
查看次数

标签 统计

perl ×4

tcl ×2

mocking ×1

mysql ×1

oop ×1

stored-procedures ×1

stub ×1

use-strict ×1