Skip to content

Commit

Permalink
fixes documentation of nqp::sha1
Browse files Browse the repository at this point in the history
Fixes documentation of nqp::sha1 (it's a serialization context opcode, not a
string opcode), and reorganizes its test code.
  • Loading branch information
thecabinet committed Jan 14, 2013
1 parent 5c3611d commit 488ad0f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
2 changes: 2 additions & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1068,6 +1068,8 @@ QAST::OperationsJAST.map_classlib_core_op('lc', $TYPE_OPS, 'lc', [$RT_STR], $RT_
QAST::OperationsJAST.map_classlib_core_op('x', $TYPE_OPS, 'x', [$RT_STR, $RT_INT], $RT_STR);
QAST::OperationsJAST.map_classlib_core_op('concat', $TYPE_OPS, 'concat', [$RT_STR, $RT_STR], $RT_STR);
QAST::OperationsJAST.map_classlib_core_op('chr', $TYPE_OPS, 'chr', [$RT_INT], $RT_STR);

# serialization context opcodes
QAST::OperationsJAST.map_classlib_core_op('sha1', $TYPE_OPS, 'sha1', [$RT_STR], $RT_STR);

#bitwise opcodes
Expand Down
1 change: 1 addition & 0 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -954,6 +954,7 @@ public static String chr(long val) {
return (new StringBuffer()).append((char) val).toString();
}

/* serialization context related opcodes */
public static String sha1(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA1");

Expand Down
22 changes: 22 additions & 0 deletions t/qast_serialization.t
@@ -0,0 +1,22 @@
use helper;

plan(1);

qast_test(
-> {
my $block := QAST::Block.new(
QAST::Op.new(
:op('say'),
QAST::Op.new(
:op('sha1'),
QAST::SVal.new( :value("larva") )
)));
QAST::CompUnit.new(
$block,
:main(QAST::Op.new(
:op('call'),
QAST::BVal.new( :value($block) )
)))
},
"2DE6BA12D336DD56ABE5B163DDF836B951A2CA7C\n",
"sha1");
21 changes: 1 addition & 20 deletions t/qast_string.t
@@ -1,6 +1,6 @@
use helper;

plan(7);
plan(6);

qast_test(
-> {
Expand Down Expand Up @@ -117,22 +117,3 @@ qast_test(
},
"B\n",
"chr");

qast_test(
-> {
my $block := QAST::Block.new(
QAST::Op.new(
:op('say'),
QAST::Op.new(
:op('sha1'),
QAST::SVal.new( :value("larva") )
)));
QAST::CompUnit.new(
$block,
:main(QAST::Op.new(
:op('call'),
QAST::BVal.new( :value($block) )
)))
},
"2DE6BA12D336DD56ABE5B163DDF836B951A2CA7C\n",
"sha1");

0 comments on commit 488ad0f

Please sign in to comment.