From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.help Subject: Re: How to assert "throw" by ERT? Date: Fri, 18 Jan 2013 07:15:43 +0400 Message-ID: <87ip6vrxk0.fsf@yandex.ru> References: <87r4ljr089.fsf@gavenkoa.example.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1358478962 11827 80.91.229.3 (18 Jan 2013 03:16:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jan 2013 03:16:02 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Oleksandr Gavenko Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 18 04:16:20 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tw2RF-0006ib-3q for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Jan 2013 04:16:17 +0100 Original-Received: from localhost ([::1]:50452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tw2Qy-0005nW-3b for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Jan 2013 22:16:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:32936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tw2Qo-0005nA-Ft for help-gnu-emacs@gnu.org; Thu, 17 Jan 2013 22:15:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tw2Qk-0004xg-I3 for help-gnu-emacs@gnu.org; Thu, 17 Jan 2013 22:15:50 -0500 Original-Received: from mail-lb0-f174.google.com ([209.85.217.174]:60217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tw2Qk-0004wz-9f for help-gnu-emacs@gnu.org; Thu, 17 Jan 2013 22:15:46 -0500 Original-Received: by mail-lb0-f174.google.com with SMTP id gi11so2347517lbb.5 for ; Thu, 17 Jan 2013 19:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=mPQpy5ao4ZPwdD3aZWwa1FFxjYCffWhc68Lm26QoZcM=; b=qD6GNN3n1HmWQOgOL0zpsYkKLUpYCpO+HrJtJyguieAcAY5jnx/Qmq917RKnY+bvWb gTWMaEf8RdbY/oKmTn2csMVn5e9xWgPPSf9NhyB0B517rfVjffSrJnb7raBEEfY3Yqnl 1yTzrReyVlVRfLph5UJ/jd2VOFeABku2w69ygAEjUUn6xHxM174aB+JjIpfAmi8xb8C3 4kNEBKPzdb/lXSQdpKpELyYvFbI9KdhjnLU2ltomulb5xOzNcrxSYHYNpqX/oqgxshCU pRbw3oYW+XzuAP1oOEmUqheiuAikLI8xtBPeuhufuilTtxrHHEgpLdqpz1VQ/JqC11GK 8eWQ== X-Received: by 10.152.133.67 with SMTP id pa3mr2973754lab.44.1358478945089; Thu, 17 Jan 2013 19:15:45 -0800 (PST) Original-Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPS id q4sm1503905lbj.15.2013.01.17.19.15.42 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 17 Jan 2013 19:15:43 -0800 (PST) In-Reply-To: <87r4ljr089.fsf@gavenkoa.example.com> (Oleksandr Gavenko's message of "Thu, 17 Jan 2013 23:03:18 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.217.174 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88699 Archived-At: Oleksandr Gavenko writes: > ERT is Emacs Lisp Regression Testing and ERT packed in GNU Emacs. > > I want to check that my function throw on some input data: > > (defun foo (arg) (unless arg (throw :invalid-arg nil))) > > I write: > > (ert-deftest foo-fail-test () > (should-error (foo nil) :type :invalid-arg) > ) > > but seems this is wrong usege or 'should-error'. In Emacs Lisp, `throw' and `catch' are a control flow mechanism, not exception handling primitives. But your function will indeed error, because it can't find a matching `catch' block. This test passes: (ert-deftest foo-fail-test () (should-error (foo nil) :type 'no-catch))