From 7454879a1d9e3948a9af21e31e9d59d5ae8b89f2 Mon Sep 17 00:00:00 2001 From: Brian Foley Date: Thu, 5 Sep 2019 10:46:22 +0200 Subject: dc: execute shouldn't pop if stack head is not a string This matches the behaviour of both GNU dc (as specified in its man page), and BSD dc (where stack_popstring() pops only if the head is a string.) Add a couple of tests to verify this behavior. function old new delta zxc_vm_process 6882 6884 +2 Signed-off-by: Brian Foley Signed-off-by: Denys Vlasenko --- testsuite/dc.tests | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'testsuite/dc.tests') diff --git a/testsuite/dc.tests b/testsuite/dc.tests index 8c3af4156..f74e3f0f5 100755 --- a/testsuite/dc.tests +++ b/testsuite/dc.tests @@ -44,6 +44,16 @@ testing "dc complex without spaces (multiple args)" \ optional FEATURE_DC_BIG # All tests below depend on FEATURE_DC_BIG +testing "dc: x should execute strings" \ + "dc -e'[40 2 +] x f'" \ + "42\n" \ + "" "" + +testing "dc: x should not execute or pop non-strings" \ + "dc -e'42 x f'" \ + "42\n" \ + "" "" + testing "dc read" \ "dc -finput" \ "2\n9\n1\n" \ -- cgit v1.2.3