Received: (at 75633-done) by debbugs.gnu.org; 14 Feb 2025 17:02:27 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 14 12:02:27 2025 Received: from localhost ([127.0.0.1]:51455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiz58-00020F-Ty for submit <at> debbugs.gnu.org; Fri, 14 Feb 2025 12:02:27 -0500 Received: from mta-13-4.privateemail.com ([198.54.127.109]:54089) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <basil@HIDDEN>) id 1tiz55-0001zs-Bj; Fri, 14 Feb 2025 12:02:25 -0500 Received: from mta-13.privateemail.com (localhost [127.0.0.1]) by mta-13.privateemail.com (Postfix) with ESMTP id 4YvddN2c0Fz3hhTp; Fri, 14 Feb 2025 12:02:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=contovou.net; s=default; t=1739552536; bh=IabS8aInawcz1Orv0tG9F8GzbKrq8EPE1dXe+Bx9J0s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=n9o6TPn+kgHkBUQZYxNxjueNh52bkZ5/KKX2i5KaeWwMYeHnnp5xbHVOKLk8vJ9Xj Vqp7y7DBT1DRagDMXcoPIQEglsXusVUO0MRdw5eX60Hm/rJjBf8p3W+Bdfzbw9Bc49 A24OO0vFdBlhcsNs2OC+Ia2pK8/U/JoUJRanWo4VI+NkruhbS08LLqafsMYNSmr7Lj ChRnVIXC3yAYgYh46rYa897WjeWfQNRzW2VFT4k52Slh7HkL9mYgKA+J7agr1aTL2u MkPNuk9oYPLbTXntF/knYWbXua8iU0zp6l0058s3KJHDgFv3Z0hyznQJvLXwqMsgRB VNjYRiT0pmL2w== Received: from localhost (unknown [31.46.244.117]) by mta-13.privateemail.com (Postfix) with ESMTPA; Fri, 14 Feb 2025 12:02:11 -0500 (EST) From: "Basil L. Contovounesios" <basil@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib In-Reply-To: <CADwFkmmbdpn=KoUzVR50Ruw5VZ=O0WO+nGwRfoKZHxStyVi2YQ@HIDDEN> References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> <87r04qn2t0.fsf@HIDDEN> <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> <87wmdt7m7k.fsf@HIDDEN> <CADwFkmk=dF_pc01P9t28GrA7nedX4LfxFi_cU7GMA1GbzyP5-g@HIDDEN> <87mseobn6y.fsf@HIDDEN> <CADwFkmmbdpn=KoUzVR50Ruw5VZ=O0WO+nGwRfoKZHxStyVi2YQ@HIDDEN> Date: Fri, 14 Feb 2025 18:02:05 +0100 Message-ID: <87frkge9yq.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75633-done Cc: 75633-done <at> debbugs.gnu.org, eliz@HIDDEN, Ahmed Khanzada <me@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) close 75633 31.1 quit Stefan Kangas [2025-02-14 09:53 -0600] wrote: > "Basil L. Contovounesios" <basil@HIDDEN> writes: >> Stefan Kangas [2025-02-13 21:38 -0800] wrote: >> >> Consolidate some cl-lib tests >> 0edf094e54c 2025-02-14 15:42:52 +0100 >> https://git.sv.gnu.org/cgit/emacs.git/commit/?id=0edf094e54c > > Thanks, does that mean that we can close this bug? I think pretty much everything was addressed, so I'd say so. Ahmed, please feel free to reply here (or submit a new report) when you get to testing the tree functions, and thanks in advance :). -- Basil
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available."Basil L. Contovounesios" <basil@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 14 Feb 2025 15:53:45 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 14 10:53:45 2025 Received: from localhost ([127.0.0.1]:51317 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiy0e-00077T-V4 for submit <at> debbugs.gnu.org; Fri, 14 Feb 2025 10:53:45 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:50619) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1tiy0c-00077F-S3 for 75633 <at> debbugs.gnu.org; Fri, 14 Feb 2025 10:53:43 -0500 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5de74599749so3434189a12.1 for <75633 <at> debbugs.gnu.org>; Fri, 14 Feb 2025 07:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739548416; x=1740153216; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=7NtbXhJ6I+c0bs/BzoF+TNJgiY3H1HSHzXflsDRTVys=; b=iOvkZOsp0APbWc2U35AH7eVYHGqhXr8pCReVn382Su/M2usQAjgsHt+NpdEcSfYDyh UlcZLUnKQkySMUxo6+d7f+QrScyOtgTLoVZo6aK3y4fJbw6+nzE+HyKlMSWtJWi7OunW qiHx3dlmskW/HpLKfIjH8KhtgPzzTgFkKGST2zi3C7MmWLn8cok+2vcYKx1a/ZApXERM ow9AzDCHRUqEXjPXnAac6CQfcFsy+ZZL367Cz0eBWubfUqop9fgNt/h7lS5mMqpyTTRl Y8oU1nJKru4u4q5GtS15kV8bCHDScImhYbnaeSoNyW+KLntcQG9SlX1kIrBVhba7eFLv gHGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739548416; x=1740153216; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7NtbXhJ6I+c0bs/BzoF+TNJgiY3H1HSHzXflsDRTVys=; b=NKp2qIFdUXXxhZoVRIyzlTUviAqMSERgSd/UQY7KpXG5BBZ/ecKdRt1QZcYkqWKeYp maNLeH6o7K5lU9aWJbYqzKf9PbYmyf8WhAXuh8YQ0EZQPYXOUNXNyMPoL7uvqYOgWwb2 iZwhkjg0BtNgvB1y/eILYFoCMHs0JEc836rV1vbHPqgZUVtddh6sb++8CT/QWc3aZBr/ McpJ2liysw26Enxu1oQXe72M92DESqy742o6bFzUZ07GIQ0ZA8si5+jGn+UYVdHYK210 swvM3Nl4wY37gQ9ORUVoqp7XAvRsnD884GkZ23A/BJxOiYstJCo3NFAOeFI/VUzpJk7K xrLw== X-Forwarded-Encrypted: i=1; AJvYcCWa0q997184iyfcfM83I8f83lWUBuUuSz/ZY0YD8bepb1mkGHiRESuDoGGcVyBtnetWBlXHjw==@debbugs.gnu.org X-Gm-Message-State: AOJu0Ywt5AKfg10AaJG50+Y6czmpfco9WBZPALe0fKkIy54gGVOYojHz RelKSbGVGqWf3EL9Hm0X6jAENCf8qX5AcyXCFprlYAffe5c6VY79bE7OPiw9GATVblTys/DND6V V/mfzfBY7K6zbNFiQRrIQbTOODZQ= X-Gm-Gg: ASbGncup3vmZdkY75wBQfg1eGeLgtQpXIzaRFdfO+txw2T6osQ2z3TaOYVSBxcX1lje pxgk/4TaNYH0DUkabpJSgdevvuYaOS9xQFoQbT6ms94V0D9sZ8/YTvk5ySE7vT2HQDfVmTQM= X-Google-Smtp-Source: AGHT+IFJvQ0pxsoXxDp811/+wDBBLo/XFrEcKgz56Ez23ntmNthnCzFAYekghNGgPQhCkDxu0BmVOvDtsJrQwTsL7Fk= X-Received: by 2002:a05:6402:35d3:b0:5de:aa54:dc30 with SMTP id 4fb4d7f45d1cf-5dec9d3233cmr6447488a12.5.1739548416301; Fri, 14 Feb 2025 07:53:36 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 14 Feb 2025 09:53:35 -0600 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <87mseobn6y.fsf@HIDDEN> References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> <87r04qn2t0.fsf@HIDDEN> <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> <87wmdt7m7k.fsf@HIDDEN> <CADwFkmk=dF_pc01P9t28GrA7nedX4LfxFi_cU7GMA1GbzyP5-g@HIDDEN> <87mseobn6y.fsf@HIDDEN> MIME-Version: 1.0 Date: Fri, 14 Feb 2025 09:53:35 -0600 X-Gm-Features: AWEUYZkiUzMGud45CaLPlBFK4Nt3Hl7nAQqGSA7o-xKUUM7qjeFOEbiilJBvnmo Message-ID: <CADwFkmmbdpn=KoUzVR50Ruw5VZ=O0WO+nGwRfoKZHxStyVi2YQ@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib To: "Basil L. Contovounesios" <basil@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75633 Cc: eliz@HIDDEN, Ahmed Khanzada <me@HIDDEN>, 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) "Basil L. Contovounesios" <basil@HIDDEN> writes: > Stefan Kangas [2025-02-13 21:38 -0800] wrote: > >> "Basil L. Contovounesios" <basil@HIDDEN> writes: >> >>> I would also like to apply the attached patch that addresses the >>> aforementioned duplication and organisation of some cl-lib tests. >>> WDYT? >> >> Based on your description and the commit message, I'd say it makes >> sense. I skimmed the patch and nothing immediately stood out to me. >> >> If you think it is good to go, then please install. > > Done, thanks. > > Consolidate some cl-lib tests > 0edf094e54c 2025-02-14 15:42:52 +0100 > https://git.sv.gnu.org/cgit/emacs.git/commit/?id=0edf094e54c Thanks, does that mean that we can close this bug?
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 14 Feb 2025 14:45:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 14 09:45:02 2025 Received: from localhost ([127.0.0.1]:47832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiww9-0005LU-9R for submit <at> debbugs.gnu.org; Fri, 14 Feb 2025 09:45:02 -0500 Received: from mta-11-4.privateemail.com ([198.54.127.104]:57569) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <basil@HIDDEN>) id 1tiww0-0005L2-2s for 75633 <at> debbugs.gnu.org; Fri, 14 Feb 2025 09:44:58 -0500 Received: from mta-11.privateemail.com (localhost [127.0.0.1]) by mta-11.privateemail.com (Postfix) with ESMTP id 4YvZZk0hsbz3hhV8; Fri, 14 Feb 2025 09:44:46 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=contovou.net; s=default; t=1739544286; bh=jKGZ5qSNGGVeF5casRBY4lIl2xrMUqFDgdDTZIGdYdQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=B5URGF6wiccJusWq5LAL2V+XyyCUBpha6bBwgDSUTk9ArzjdET6A7haHuSqdtNC97 sWPglRbTNK7JHHqYffQEYs+KyGq6hdso8tLshdI2jcs0OkgenrmTmkJBVNceLly6WO lUcI7/Wmz6q/CPPsAAcStIHWua+vVW8TTscdH7QO5XSUQeLk3IA4ftBLHOz5IpmHQF 51BhWUibbVoFxsEwDNxyb0yNzOBTqXseCZrGOSBZP3LwPQ6Yw8ypOkbJ1tF/lX2CE5 4IIL9aeyCK9HmrxK+r+g+jAoW7PoH7uKWHX+kaOPVRHF2+UN03XVQKByNoFUKQ/cCi pv+i+9gF5flhQ== Received: from localhost (unknown [31.46.244.117]) by mta-11.privateemail.com (Postfix) with ESMTPA; Fri, 14 Feb 2025 09:44:42 -0500 (EST) From: "Basil L. Contovounesios" <basil@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib In-Reply-To: <CADwFkmk=dF_pc01P9t28GrA7nedX4LfxFi_cU7GMA1GbzyP5-g@HIDDEN> References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> <87r04qn2t0.fsf@HIDDEN> <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> <87wmdt7m7k.fsf@HIDDEN> <CADwFkmk=dF_pc01P9t28GrA7nedX4LfxFi_cU7GMA1GbzyP5-g@HIDDEN> Date: Fri, 14 Feb 2025 15:44:37 +0100 Message-ID: <87mseobn6y.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75633 Cc: eliz@HIDDEN, Ahmed Khanzada <me@HIDDEN>, 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Kangas [2025-02-13 21:38 -0800] wrote: > "Basil L. Contovounesios" <basil@HIDDEN> writes: > >> I would also like to apply the attached patch that addresses the >> aforementioned duplication and organisation of some cl-lib tests. >> WDYT? > > Based on your description and the commit message, I'd say it makes > sense. I skimmed the patch and nothing immediately stood out to me. > > If you think it is good to go, then please install. Done, thanks. Consolidate some cl-lib tests 0edf094e54c 2025-02-14 15:42:52 +0100 https://git.sv.gnu.org/cgit/emacs.git/commit/?id=0edf094e54c -- Basil
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 14 Feb 2025 05:38:32 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 14 00:38:32 2025 Received: from localhost ([127.0.0.1]:46606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tioPH-0006IF-JK for submit <at> debbugs.gnu.org; Fri, 14 Feb 2025 00:38:31 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:49412) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1tioPF-0006Hv-6n for 75633 <at> debbugs.gnu.org; Fri, 14 Feb 2025 00:38:29 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5de5a853090so3676260a12.3 for <75633 <at> debbugs.gnu.org>; Thu, 13 Feb 2025 21:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739511503; x=1740116303; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=pRfG4Vm7Z+fKOrrNk8o+HsUQL//WXx/IZOVUAFRLJy0=; b=VQ8p8nsNyPHjU5mCj4GSZzrJzev3RMTVr5cN/6rnrXxg1mH4ykF+flQuveZBgwfxc7 CfdMokFojw/0QAQHDviauu286oMMFV8inohkEyGyXhW7JNQUghWJD4dV98j47YuseMar zBZvdTMxo+ewBChRWpagspUA6WaMXmTZTl8c3XDXhhmp6Ccl38i1L7gIrFFnpGo8rwRW FicNoyp7KrY/aRXPLDn1gAQ2Wah8MNEe6wfzu67nv1OYRMhF0CkDE7xW8eV5iyDJ7Lq1 i9dlaJkNlF9A5NLcr7uz2F0j/RbwJIGBN6p7aLXlDcMFnojhVLirvdGJP+PGTrHqBe3D JhBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739511503; x=1740116303; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pRfG4Vm7Z+fKOrrNk8o+HsUQL//WXx/IZOVUAFRLJy0=; b=hnMjFqMKAxdIlvnjUwrX49u1QraSarkBO97fcphNdse2iac5yjBzN1EK2wYPN5aUuR Gme9mqPEPZwv2VFq4vw8iIOKGSOxunbcJiNkGhKbP6I0KEgfKKMMJQzrKdEMPy6kPXrz JE7CZP3LF/7d79k8vVU6NGNjNgJABP0wr7fyzx1ix/QVN3NiAITQ/ZSlyPOmcbqppAKm Qo8v8bHnrxShHYrvdRosP8B9RaJjrUcJvnDBuxhaFrMBa44dPaTtBtmmFGmli3VeoWuh OKxHsOMGeKRUXGsFhzWJalVMdCHWJcAzRW7Skdkip9xPzxaTHFcPqaKAMFLvrOEe+PFQ 4krA== X-Forwarded-Encrypted: i=1; AJvYcCVEZs8pAbmp2B/hmlf9nY1JM/TGVhOJ1gIpHfn8ZxreYhj0rHyPIJyal15/yPgjzqvgWlpu/Q==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yz9g77QQaTOMsQMfoI3UpC2Xy5zXW7hzXXiMdmVLIPyn8I3DHxH VmCR+xEo25+RTI4Cn+Ko3xiJrMdXCXdZRQRiVka8NcCi+ZueptCWyjluHZ+hQGNXrPgagIR+M9w +7Ztx8QE9klIKsPaRegK9/NlkNlI= X-Gm-Gg: ASbGnctaxJlea9rZj3ptFxrtPb1fsd/yqZpjo9qDCOsCeovSfLEwa1zTUSCOIpOSx3m VFnPppb3ocZ27khucmYiBx/9SywTQInD0By04BCNepVOJPGsv9LT1N6OL9IiqzTphjYK+lNU= X-Google-Smtp-Source: AGHT+IELMmRrdiIVjfALbi+sfqPV9ATRWVEdlxfkyzvbGTK/t6lUnKZKFo+GbJMgOarJ86SGWT683kToi8ojPW5vj+A= X-Received: by 2002:a05:6402:2548:b0:5de:d942:a47d with SMTP id 4fb4d7f45d1cf-5ded942a55cmr2824823a12.28.1739511502531; Thu, 13 Feb 2025 21:38:22 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 13 Feb 2025 21:38:21 -0800 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <87wmdt7m7k.fsf@HIDDEN> References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> <87r04qn2t0.fsf@HIDDEN> <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> <87wmdt7m7k.fsf@HIDDEN> MIME-Version: 1.0 Date: Thu, 13 Feb 2025 21:38:21 -0800 X-Gm-Features: AWEUYZlPMeVZj4OarbSWl30zdbeDOJID2zlrhi7GEKUrhN99yjERutsOUJ_DeQQ Message-ID: <CADwFkmk=dF_pc01P9t28GrA7nedX4LfxFi_cU7GMA1GbzyP5-g@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib To: "Basil L. Contovounesios" <basil@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75633 Cc: eliz@HIDDEN, Ahmed Khanzada <me@HIDDEN>, 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) "Basil L. Contovounesios" <basil@HIDDEN> writes: > I would also like to apply the attached patch that addresses the > aforementioned duplication and organisation of some cl-lib tests. > WDYT? Based on your description and the commit message, I'd say it makes sense. I skimmed the patch and nothing immediately stood out to me. If you think it is good to go, then please install. Thanks in advance.
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 13 Feb 2025 18:07:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 13 13:07:31 2025 Received: from localhost ([127.0.0.1]:45408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tidcW-0002Il-W1 for submit <at> debbugs.gnu.org; Thu, 13 Feb 2025 13:07:31 -0500 Received: from mta-06-4.privateemail.com ([198.54.122.146]:35750) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <basil@HIDDEN>) id 1tidcR-0002IV-U7 for 75633 <at> debbugs.gnu.org; Thu, 13 Feb 2025 13:07:26 -0500 Received: from mta-06.privateemail.com (localhost [127.0.0.1]) by mta-06.privateemail.com (Postfix) with ESMTP id 4Yv36t19K1z3hhV4; Thu, 13 Feb 2025 13:07:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=contovou.net; s=default; t=1739470038; bh=LanVQQZp5yPZmWEE2X1qd9EuagJ/61CdcTuH6npoSOA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=aKm14Fa6beDxdZCHkr8FOOuvvf9FyBFwyP/Qc6rf/WACvTsVPko6X/5dzMp7S9mQ5 TNNDXlsk38fh84YUMQKOKFoB0vv2AG6gyW9hqkjUbQjltrk9LnyjSw41T2afB8e42w O+0ZkxM63SM+PrDYr8JD9e7zq1hX+MnxEvSsFGGdXwuFbYrYJYkju6nRVxWWu2ccOX khfUpZdLH7rZuZtbsTnEsBxvdhRoiTft8vVExElRDrj5U2Xtu4D5Cd7kwZym3Lv1S7 +7GTudwj1BCDbgVBokeb1khy43IinfZn39/jf9ybriX7+35FeXhs+Jk7imqcyG83h9 YlUCNDG+eVtTg== Received: from localhost (unknown [146.70.196.137]) by mta-06.privateemail.com (Postfix) with ESMTPA; Thu, 13 Feb 2025 13:07:13 -0500 (EST) From: "Basil L. Contovounesios" <basil@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib In-Reply-To: <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> <87r04qn2t0.fsf@HIDDEN> <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> Date: Thu, 13 Feb 2025 19:07:11 +0100 Message-ID: <87wmdt7m7k.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75633 Cc: eliz@HIDDEN, Ahmed Khanzada <me@HIDDEN>, 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Stefan Kangas [2025-02-10 23:43 -0800] wrote: > Can we please apply your patch now? It would be nice not to have to see > those warnings from the tests. Yes, done: Fix cl-seq-tests.el 52034675a2e 2025-02-13 18:40:26 +0100 https://git.sv.gnu.org/cgit/emacs.git/commit/?id=52034675a2e I would also like to apply the attached patch that addresses the aforementioned duplication and organisation of some cl-lib tests. WDYT? Thanks, -- Basil --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Consolidate-some-cl-lib-tests.patch From 6a8104030eca51bac6f79d095ce60971b32bcb4b Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" <basil@HIDDEN> Date: Sun, 2 Feb 2025 17:18:52 +0100 Subject: [PATCH] Consolidate some cl-lib tests For discussion, see bug#75633#16 and the following thread: https://lists.gnu.org/r/emacs-devel/2025-02/msg00053.html * test/lisp/emacs-lisp/cl-extra-tests.el (cl-lib-test-remprop) (cl-lib-test-coerce-to-vector, cl-parse-integer): Move here from cl-lib-tests.el. (cl-extra-test-remprop): Remove duplicate test, folding body... (cl-get): ...into this test. (cl-extra-test-concatenate): Remove duplicate test, folding body... (cl-concatenate): ...into this test. * test/lisp/emacs-lisp/cl-lib-tests.el: Update historic commentary. (cl-lib-test-remprop, cl-lib-test-coerce-to-vector) (cl-parse-integer): Move to cl-extra-tests.el. (cl-lib-test-remove-if-not, cl-lib-test-remove) (cl-lib-test-set-functions, cl-lib-test-string-position) (cl-lib-test-mismatch, cl-nset-difference): Move to cl-seq-tests.el. (cl-lib-test-gensym, cl-lib-keyword-names-versus-values) (cl-lib-empty-keyargs, mystruct, cl-lib-struct-accessors) (cl-lib-struct-constructors, cl-lib-arglist-performance, cl-the) (cl-flet-test, cl-lib-test-typep, cl-lib-symbol-macrolet) (cl-lib-symbol-macrolet-4+5, cl-lib-symbol-macrolet-2) (cl-lib-symbol-macrolet-hide, cl-lib-defstruct-record): Move to cl-macs-tests.el. (cl-lib-test-endp): Remove duplicate test, folding body into cl-seq-endp-test. (cl-lib-set-difference): Remove duplicate test, folding body into cl-set-difference-test. * test/lisp/emacs-lisp/cl-macs-tests.el: Do not require cl-macs and pcase. (mystruct, cl-lib-struct-accessors, cl-lib-struct-constructors) (cl-lib-arglist-performance, cl-lib-defstruct-record) (cl-lib-symbol-macrolet, cl-lib-symbol-macrolet-4+5) (cl-lib-symbol-macrolet-2, cl-lib-symbol-macrolet-hide, cl-flet-test) (cl-lib-keyword-names-versus-values, cl-lib-empty-keyargs) (cl-lib-test-gensym, cl-the, cl-lib-test-typep): Move here from cl-lib-tests.el. (cl-case-error, cl-case-warning): Fix indentation. * test/lisp/emacs-lisp/cl-seq-tests.el: Require cl-lib rather than cl-seq. (cl-seq-endp-test): Absorb body of cl-lib-test-endp. (cl-lib-test-remove, cl-lib-test-remove-if-not) (cl-lib-test-string-position, cl-lib-test-mismatch) (cl-lib-test-set-functions, cl-nset-difference): Move here from cl-lib-tests.el. (cl-set-difference-test): Absorb body of cl-lib-set-difference. --- test/lisp/emacs-lisp/cl-extra-tests.el | 70 +++++- test/lisp/emacs-lisp/cl-lib-tests.el | 322 +------------------------ test/lisp/emacs-lisp/cl-macs-tests.el | 134 +++++++++- test/lisp/emacs-lisp/cl-seq-tests.el | 153 +++++++++++- 4 files changed, 332 insertions(+), 347 deletions(-) diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el index bec4e373201..75533b36f29 100644 --- a/test/lisp/emacs-lisp/cl-extra-tests.el +++ b/test/lisp/emacs-lisp/cl-extra-tests.el @@ -22,12 +22,55 @@ (require 'cl-lib) (require 'ert) +(ert-deftest cl-lib-test-remprop () + (let ((x (cl-gensym))) + (should (equal (symbol-plist x) '())) + ;; Remove nonexistent property on empty plist. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '())) + (put x 'a 1) + (should (equal (symbol-plist x) '(a 1))) + ;; Remove nonexistent property on nonempty plist. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '(a 1))) + (put x 'b 2) + (put x 'c 3) + (put x 'd 4) + (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) + ;; Remove property that is neither first nor last. + (cl-remprop x 'c) + (should (equal (symbol-plist x) '(a 1 b 2 d 4))) + ;; Remove last property from a plist of length >1. + (cl-remprop x 'd) + (should (equal (symbol-plist x) '(a 1 b 2))) + ;; Remove first property from a plist of length >1. + (cl-remprop x 'a) + (should (equal (symbol-plist x) '(b 2))) + ;; Remove property when there is only one. + (cl-remprop x 'b) + (should (equal (symbol-plist x) '())))) + (ert-deftest cl-get () (put 'cl-get-test 'x 1) (put 'cl-get-test 'y nil) (should (eq (cl-get 'cl-get-test 'x) 1)) (should (eq (cl-get 'cl-get-test 'y :none) nil)) - (should (eq (cl-get 'cl-get-test 'z :none) :none))) + (should (eq (cl-get 'cl-get-test 'z :none) :none)) + (let ((sym (make-symbol "test"))) + (put sym 'foo 'bar) + (should (equal (cl-get sym 'foo) 'bar)) + (cl-remprop sym 'foo) + (should (equal (cl-get sym 'foo 'default) 'default)))) + +(ert-deftest cl-lib-test-coerce-to-vector () + (let* ((a (vector)) + (b (vector 1 a 3)) + (c (list)) + (d (list b a))) + (should (eql (cl-coerce a 'vector) a)) + (should (eql (cl-coerce b 'vector) b)) + (should (equal (cl-coerce c 'vector) (vector))) + (should (equal (cl-coerce d 'vector) (vector b a))))) (ert-deftest cl-extra-test-coerce () (should (equal (cl-coerce "abc" 'list) '(?a ?b ?c))) @@ -152,7 +195,8 @@ cl-concatenate (should (equal (cl-concatenate 'vector [1 2 3] [4 5 6]) [1 2 3 4 5 6])) (should (equal (cl-concatenate 'string "123" "456") - "123456"))) + "123456")) + (should (equal (cl-concatenate 'list '(1 2) '(3 4) '(5 6)) '(1 2 3 4 5 6)))) (ert-deftest cl-extra-test-mapcan () (should (equal (cl-mapcan #'list '(1 2 3)) '(1 2 3))) @@ -258,6 +302,17 @@ cl-extra-test-signum (should (equal (cl-signum -10) -1)) (should (equal (cl-signum 0) 0))) +(ert-deftest cl-parse-integer () + (should-error (cl-parse-integer "abc")) + (should (null (cl-parse-integer "abc" :junk-allowed t))) + (should (null (cl-parse-integer "" :junk-allowed t))) + (should (= 342391 (cl-parse-integer "0123456789" :radix 8 :junk-allowed t))) + (should-error (cl-parse-integer "0123456789" :radix 8)) + (should (= -239 (cl-parse-integer "-efz" :radix 16 :junk-allowed t))) + (should-error (cl-parse-integer "efz" :radix 16)) + (should (= 239 (cl-parse-integer "zzef" :radix 16 :start 2))) + (should (= -123 (cl-parse-integer " -123 ")))) + (ert-deftest cl-extra-test-parse-integer () (should (equal (cl-parse-integer "10") 10)) (should (equal (cl-parse-integer "-10") -10)) @@ -274,10 +329,6 @@ cl-extra-test-subseq (should (equal (cl-subseq '(1 2 3 4 5) 2) '(3 4 5))) (should (equal (cl-subseq '(1 2 3 4 5) 1 3) '(2 3)))) -(ert-deftest cl-extra-test-concatenate () - (should (equal (cl-concatenate 'string "hello " "world") "hello world")) - (should (equal (cl-concatenate 'list '(1 2) '(3 4) '(5 6)) '(1 2 3 4 5 6)))) - (ert-deftest cl-extra-test-revappend () (should (equal (cl-revappend '(1 2 3) '(4 5 6)) '(3 2 1 4 5 6)))) @@ -297,11 +348,4 @@ cl-extra-test-tailp (should (cl-tailp l l)) (should (not (cl-tailp '(4 5) l))))) -(ert-deftest cl-extra-test-remprop () - (let ((sym (make-symbol "test"))) - (put sym 'foo 'bar) - (should (equal (cl-get sym 'foo) 'bar)) - (cl-remprop sym 'foo) - (should (equal (cl-get sym 'foo 'default) 'default)))) - ;;; cl-extra-tests.el ends here diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index ff860d94468..12de268bced 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -19,229 +19,14 @@ ;;; Commentary: -;; Extracted from ert-tests.el, back when ert used to reimplement some -;; cl functions. +;; Some of these tests were extracted from ert-tests.el, back when ert +;; used to reimplement some cl functions. ;;; Code: (require 'cl-lib) (require 'ert) -(ert-deftest cl-lib-test-remprop () - (let ((x (cl-gensym))) - (should (equal (symbol-plist x) '())) - ;; Remove nonexistent property on empty plist. - (cl-remprop x 'b) - (should (equal (symbol-plist x) '())) - (put x 'a 1) - (should (equal (symbol-plist x) '(a 1))) - ;; Remove nonexistent property on nonempty plist. - (cl-remprop x 'b) - (should (equal (symbol-plist x) '(a 1))) - (put x 'b 2) - (put x 'c 3) - (put x 'd 4) - (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) - ;; Remove property that is neither first nor last. - (cl-remprop x 'c) - (should (equal (symbol-plist x) '(a 1 b 2 d 4))) - ;; Remove last property from a plist of length >1. - (cl-remprop x 'd) - (should (equal (symbol-plist x) '(a 1 b 2))) - ;; Remove first property from a plist of length >1. - (cl-remprop x 'a) - (should (equal (symbol-plist x) '(b 2))) - ;; Remove property when there is only one. - (cl-remprop x 'b) - (should (equal (symbol-plist x) '())))) - -(ert-deftest cl-lib-test-remove-if-not () - (let ((list (list 'a 'b 'c 'd)) - (i 0)) - (let ((result (cl-remove-if-not (lambda (x) - (should (eql x (nth i list))) - (cl-incf i) - (member i '(2 3))) - list))) - (should (equal i 4)) - (should (equal result '(b c))) - (should (equal list '(a b c d))))) - (should (equal '() - (cl-remove-if-not (lambda (_x) (should nil)) '())))) - -(ert-deftest cl-lib-test-remove () - (let ((list (list 'a 'b 'c 'd)) - (key-index 0) - (test-index 0)) - (let ((result - (cl-remove 'foo list - :key (lambda (x) - (should (eql x (nth key-index list))) - (prog1 - (list key-index x) - (cl-incf key-index))) - :test - (lambda (a b) - (should (eql a 'foo)) - (should (equal b (list test-index - (nth test-index list)))) - (cl-incf test-index) - (member test-index '(2 3)))))) - (should (equal key-index 4)) - (should (equal test-index 4)) - (should (equal result '(a d))) - (should (equal list '(a b c d))))) - (let ((x (cons nil nil)) - (y (cons nil nil))) - (should (equal (cl-remove x (list x y)) - ;; or (list x), since we use `equal' -- the - ;; important thing is that only one element got - ;; removed, this proves that the default test is - ;; `eql', not `equal' - (list y))))) - - -(ert-deftest cl-lib-test-set-functions () - (let ((c1 (cons nil nil)) - (c2 (cons nil nil)) - (sym (make-symbol "a"))) - (let ((e '()) - (a (list 'a 'b sym nil "" "x" c1 c2)) - (b (list c1 'y 'b sym 'x))) - (should (equal (cl-set-difference e e) e)) - (should (equal (cl-set-difference a e) a)) - (should (equal (cl-set-difference e a) e)) - (should (equal (cl-set-difference a a) e)) - (should (equal (cl-set-difference b e) b)) - (should (equal (cl-set-difference e b) e)) - (should (equal (cl-set-difference b b) e)) - ;; Note: this test (and others) is sensitive to the order of the - ;; result, which is not documented. - (should (equal (cl-set-difference a b) (list 'a nil "" "x" c2))) - (should (equal (cl-set-difference b a) (list 'y 'x))) - - ;; We aren't testing whether this is really using `eq' rather than `eql'. - (should (equal (cl-set-difference e e :test 'eq) e)) - (should (equal (cl-set-difference a e :test 'eq) a)) - (should (equal (cl-set-difference e a :test 'eq) e)) - (should (equal (cl-set-difference a a :test 'eq) e)) - (should (equal (cl-set-difference b e :test 'eq) b)) - (should (equal (cl-set-difference e b :test 'eq) e)) - (should (equal (cl-set-difference b b :test 'eq) e)) - (should (equal (cl-set-difference a b :test 'eq) (list 'a nil "" "x" c2))) - (should (equal (cl-set-difference b a :test 'eq) (list 'y 'x))) - - (should (equal (cl-union e e) e)) - (should (equal (cl-union a e) a)) - (should (equal (cl-union e a) a)) - (should (equal (cl-union a a) a)) - (should (equal (cl-union b e) b)) - (should (equal (cl-union e b) b)) - (should (equal (cl-union b b) b)) - (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) - - (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) - - (should (equal (cl-intersection e e) e)) - (should (equal (cl-intersection a e) e)) - (should (equal (cl-intersection e a) e)) - (should (equal (cl-intersection a a) a)) - (should (equal (cl-intersection b e) e)) - (should (equal (cl-intersection e b) e)) - (should (equal (cl-intersection b b) b)) - (should (equal (cl-intersection a b) (list sym 'b c1))) - (should (equal (cl-intersection b a) (list sym 'b c1)))))) - -(ert-deftest cl-lib-test-gensym () - ;; Since the expansion of `should' calls `cl-gensym' and thus has a - ;; side-effect on `cl--gensym-counter', we have to make sure all - ;; macros in our test body are expanded before we rebind - ;; `cl--gensym-counter' and run the body. Otherwise, the test would - ;; fail if run interpreted. - (let ((body (byte-compile - '(lambda () - (should (equal (symbol-name (cl-gensym)) "G0")) - (should (equal (symbol-name (cl-gensym)) "G1")) - (should (equal (symbol-name (cl-gensym)) "G2")) - (should (equal (symbol-name (cl-gensym "foo")) "foo3")) - (should (equal (symbol-name (cl-gensym "bar")) "bar4")) - (should (equal cl--gensym-counter 5)))))) - (let ((cl--gensym-counter 0)) - (funcall body)))) - -(ert-deftest cl-lib-test-coerce-to-vector () - (let* ((a (vector)) - (b (vector 1 a 3)) - (c (list)) - (d (list b a))) - (should (eql (cl-coerce a 'vector) a)) - (should (eql (cl-coerce b 'vector) b)) - (should (equal (cl-coerce c 'vector) (vector))) - (should (equal (cl-coerce d 'vector) (vector b a))))) - -(ert-deftest cl-lib-test-string-position () - (should (eql (cl-position ?x "") nil)) - (should (eql (cl-position ?a "abc") 0)) - (should (eql (cl-position ?b "abc") 1)) - (should (eql (cl-position ?c "abc") 2)) - (should (eql (cl-position ?d "abc") nil)) - (should (eql (cl-position ?A "abc") nil))) - -(ert-deftest cl-lib-test-mismatch () - (should (eql (cl-mismatch "" "") nil)) - (should (eql (cl-mismatch "" "a") 0)) - (should (eql (cl-mismatch "a" "a") nil)) - (should (eql (cl-mismatch "ab" "a") 1)) - (should (eql (cl-mismatch "Aa" "aA") 0)) - (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) - -(ert-deftest cl-lib-keyword-names-versus-values () - (should (equal - (funcall (cl-function (lambda (&key a b) (list a b))) - :b :a :a 42) - '(42 :a)))) - -(ert-deftest cl-lib-empty-keyargs () - (should-error (funcall (cl-function (lambda (&key) 1)) - :b 1))) - -(cl-defstruct (mystruct - (:constructor cl-lib--con-1 (&aux (abc 1))) - (:constructor cl-lib--con-2 (&optional def) "Constructor docstring.")) - "General docstring." - (abc 5 :readonly t) (def nil)) -(ert-deftest cl-lib-struct-accessors () - (let ((x (make-mystruct :abc 1 :def 2))) - (should (eql (cl-struct-slot-value 'mystruct 'abc x) 1)) - (should (eql (cl-struct-slot-value 'mystruct 'def x) 2)) - (setf (cl-struct-slot-value 'mystruct 'def x) -1) - (should (eql (cl-struct-slot-value 'mystruct 'def x) -1)) - (should (eql (cl-struct-slot-offset 'mystruct 'abc) 1)) - (should-error (cl-struct-slot-offset 'mystruct 'marypoppins)) - (should (pcase (cl-struct-slot-info 'mystruct) - (`((cl-tag-slot) (abc 5 :readonly t) - (def . ,(or 'nil '(nil)))) - t))))) -(ert-deftest cl-lib-struct-constructors () - (should (string-match "\\`Constructor docstring." - (documentation 'cl-lib--con-2 t))) - (should (mystruct-p (cl-lib--con-1))) - (should (mystruct-p (cl-lib--con-2)))) - -(ert-deftest cl-lib-arglist-performance () - ;; An `&aux' should not cause lambda's arglist to be turned into an &rest - ;; that's parsed by hand. - (should (equal () (help-function-arglist 'cl-lib--con-1))) - (should (pcase (help-function-arglist 'cl-lib--con-2) - (`(&optional ,_) t)))) - -(ert-deftest cl-the () - (should (eql (cl-the integer 42) 42)) - (should-error (cl-the integer "abc")) - (let ((side-effect 0)) - (should (= (cl-the integer (cl-incf side-effect)) 1)) - (should (= side-effect 1)))) - (ert-deftest cl-lib-test-pushnew () (let ((list '(1 2 3))) (cl-pushnew 0 list) @@ -468,12 +253,6 @@ cl-lib-test-pairlis (should (equal (cl-pairlis '(a nil c) '(1 2 3)) '((a . 1) (nil . 2) (c . 3)))) (should (equal (cl-pairlis '(a b c) '(1 nil 3)) '((a . 1) (b) (c . 3))))) -(ert-deftest cl-lib-test-endp () - (should (cl-endp '())) - (should-not (cl-endp '(1))) - (should-error (cl-endp 1) :type 'wrong-type-argument) - (should-error (cl-endp [1]) :type 'wrong-type-argument)) - (ert-deftest cl-lib-test-nth-value () (let ((vals (cl-values 2 3))) (should (= (cl-nth-value 0 vals) 2)) @@ -544,70 +323,6 @@ cl-lib-adjoin-test (should-error (cl-adjoin 1 nums :key 'int-to-string :test-not myfn-p) :type 'wrong-type-argument))) -(ert-deftest cl-parse-integer () - (should-error (cl-parse-integer "abc")) - (should (null (cl-parse-integer "abc" :junk-allowed t))) - (should (null (cl-parse-integer "" :junk-allowed t))) - (should (= 342391 (cl-parse-integer "0123456789" :radix 8 :junk-allowed t))) - (should-error (cl-parse-integer "0123456789" :radix 8)) - (should (= -239 (cl-parse-integer "-efz" :radix 16 :junk-allowed t))) - (should-error (cl-parse-integer "efz" :radix 16)) - (should (= 239 (cl-parse-integer "zzef" :radix 16 :start 2))) - (should (= -123 (cl-parse-integer " -123 ")))) - -(ert-deftest cl-flet-test () - (should (equal (cl-flet ((f1 (x) x)) (let ((x #'f1)) (funcall x 5))) 5))) - -(ert-deftest cl-lib-test-typep () - (cl-deftype cl-lib-test-type (&optional x) `(member ,x)) - ;; Make sure we correctly implement the rule that deftype's optional args - ;; default to `*' rather than to nil. - (should (cl-typep '* 'cl-lib-test-type)) - (should-not (cl-typep 1 'cl-lib-test-type))) - -(ert-deftest cl-lib-symbol-macrolet () - ;; bug#26325 - (should (equal (cl-flet ((f (x) (+ x 5))) - (let ((x 5)) - (f (+ x 6)))) - ;; Go through `eval', otherwise the macro-expansion - ;; error prevents running the whole test suite :-( - (eval '(cl-symbol-macrolet ((f (+ x 6))) - (cl-flet ((f (x) (+ x 5))) - (let ((x 5)) - (f f)))) - t)))) - -(defmacro cl-lib-symbol-macrolet-4+5 () - ;; bug#26068 - (let* ((sname "x") - (s1 (make-symbol sname)) - (s2 (make-symbol sname))) - `(cl-symbol-macrolet ((,s1 4) - (,s2 5)) - (+ ,s1 ,s2)))) - -(ert-deftest cl-lib-symbol-macrolet-2 () - (should (equal (cl-lib-symbol-macrolet-4+5) (+ 4 5)))) - - -(ert-deftest cl-lib-symbol-macrolet-hide () - ;; bug#26325, bug#26073 - (should (equal (let ((y 5)) - (cl-symbol-macrolet ((x y)) - (list x - (let ((x 6)) (list x y)) - (cl-letf ((x 6)) (list x y)) - (apply (lambda (x) (+ x 1)) (list 8))))) - '(5 (6 5) (6 6) 9)))) - -(ert-deftest cl-lib-defstruct-record () - (cl-defstruct foo x) - (let ((x (make-foo :x 42))) - (should (recordp x)) - (should (eq (type-of x) 'foo)) - (should (eql (foo-x x) 42)))) - (ert-deftest old-struct () (cl-defstruct foo x) (with-suppressed-warnings ((obsolete cl-old-struct-compat-mode)) @@ -638,37 +353,4 @@ cl-constantly (should (equal (mapcar (cl-constantly 3) '(a b c d)) '(3 3 3 3)))) -(ert-deftest cl-lib-set-difference () - ;; our set-difference preserves order, though it is not required to - ;; by cl standards. Nevertheless better keep that invariant - (should (equal (cl-set-difference '(1 2 3 4) '(3 4 5 6)) - '(1 2)))) - -(ert-deftest cl-nset-difference () - ;; our nset-difference doesn't - (let* ((l1 (list 1 2 3 4)) (l2 '(3 4 5 6)) - (diff (cl-nset-difference l1 l2))) - (should (memq 1 diff)) - (should (memq 2 diff)) - (should (= (length diff) 2)) - (should (equal l2 '(3 4 5 6)))) - (let* ((l1 (list "1" "2" "3" "4")) (l2 '("3" "4" "5" "6")) - (diff (cl-nset-difference l1 l2 :test #'equal))) - (should (member "1" diff)) - (should (member "2" diff)) - (should (= (length diff) 2)) - (should (equal l2 '("3" "4" "5" "6")))) - (let* ((l1 (list '(a . 1) '(b . 2) '(c . 3) '(d . 4))) - (l2 (list '(c . 3) '(d . 4) '(e . 5) '(f . 6))) - (diff (cl-nset-difference l1 l2 :key #'car))) - (should (member '(a . 1) diff)) - (should (member '(b . 2) diff)) - (should (= (length diff) 2))) - (let* ((l1 (list '("a" . 1) '("b" . 2) '("c" . 3) '("d" . 4))) - (l2 (list '("c" . 3) '("d" . 4) '("e" . 5) '("f" . 6))) - (diff (cl-nset-difference l1 l2 :key #'car :test #'string=))) - (should (member '("a" . 1) diff)) - (should (member '("b" . 2) diff)) - (should (= (length diff) 2)))) - ;;; cl-lib-tests.el ends here diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 628bae36e48..4fa5c4edba1 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -22,11 +22,9 @@ ;;; Code: (require 'cl-lib) -(require 'cl-macs) (require 'edebug) (require 'ert) (require 'ert-x) -(require 'pcase) ;;;; cl-loop tests -- many adapted from Steele's CLtL2 @@ -518,6 +516,45 @@ cl-macs-loop-for-as-equals-and collect (list k x)))))) +(cl-defstruct (mystruct + (:constructor cl-lib--con-1 (&aux (abc 1))) + (:constructor cl-lib--con-2 (&optional def) "Constructor docstring.")) + "General docstring." + (abc 5 :readonly t) (def nil)) + +(ert-deftest cl-lib-struct-accessors () + (let ((x (make-mystruct :abc 1 :def 2))) + (should (eql (cl-struct-slot-value 'mystruct 'abc x) 1)) + (should (eql (cl-struct-slot-value 'mystruct 'def x) 2)) + (setf (cl-struct-slot-value 'mystruct 'def x) -1) + (should (eql (cl-struct-slot-value 'mystruct 'def x) -1)) + (should (eql (cl-struct-slot-offset 'mystruct 'abc) 1)) + (should-error (cl-struct-slot-offset 'mystruct 'marypoppins)) + (should (pcase (cl-struct-slot-info 'mystruct) + (`((cl-tag-slot) (abc 5 :readonly t) + (def . ,(or 'nil '(nil)))) + t))))) + +(ert-deftest cl-lib-struct-constructors () + (should (string-match "\\`Constructor docstring." + (documentation 'cl-lib--con-2 t))) + (should (mystruct-p (cl-lib--con-1))) + (should (mystruct-p (cl-lib--con-2)))) + +(ert-deftest cl-lib-arglist-performance () + ;; An `&aux' should not cause lambda's arglist to be turned into an &rest + ;; that's parsed by hand. + (should (equal () (help-function-arglist 'cl-lib--con-1))) + (should (pcase (help-function-arglist 'cl-lib--con-2) + (`(&optional ,_) t)))) + +(ert-deftest cl-lib-defstruct-record () + (cl-defstruct foo x) + (let ((x (make-foo :x 42))) + (should (recordp x)) + (should (eq (type-of x) 'foo)) + (should (eql (foo-x x) 42)))) + (ert-deftest cl-defstruct/builtin-type () (should-error (macroexpand '(cl-defstruct hash-table)) @@ -563,6 +600,41 @@ cl-macs-test--symbol-macrolet m))) '(42 5 42)))) +(ert-deftest cl-lib-symbol-macrolet () + ;; bug#26325 + (should (equal (cl-flet ((f (x) (+ x 5))) + (let ((x 5)) + (f (+ x 6)))) + ;; Go through `eval', otherwise the macro-expansion + ;; error prevents running the whole test suite :-( + (eval '(cl-symbol-macrolet ((f (+ x 6))) + (cl-flet ((f (x) (+ x 5))) + (let ((x 5)) + (f f)))) + t)))) + +(defmacro cl-lib-symbol-macrolet-4+5 () + ;; bug#26068 + (let* ((sname "x") + (s1 (make-symbol sname)) + (s2 (make-symbol sname))) + `(cl-symbol-macrolet ((,s1 4) + (,s2 5)) + (+ ,s1 ,s2)))) + +(ert-deftest cl-lib-symbol-macrolet-2 () + (should (equal (cl-lib-symbol-macrolet-4+5) (+ 4 5)))) + +(ert-deftest cl-lib-symbol-macrolet-hide () + ;; bug#26325, bug#26073 + (should (equal (let ((y 5)) + (cl-symbol-macrolet ((x y)) + (list x + (let ((x 6)) (list x y)) + (cl-letf ((x 6)) (list x y)) + (apply (lambda (x) (+ x 1)) (list 8))))) + '(5 (6 5) (6 6) 9)))) + (ert-deftest cl-macs-loop-conditional-step-clauses () "These tests failed under the initial fixes in #bug#29799." (should (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) @@ -718,6 +790,9 @@ cl-macs--labels (f lex-var))))) (should (equal (f nil) 'a))))) +(ert-deftest cl-flet-test () + (should (equal (cl-flet ((f1 (x) x)) (let ((x #'f1)) (funcall x 5))) 5))) + (ert-deftest cl-macs--test-flet-block () (should (equal (cl-block f1 (cl-flet ((f1 (a) (cons (cl-return-from f1 a) 6))) @@ -803,9 +878,9 @@ cl-case-error (cl-ecase val (t 1) (123 2)) (cl-ecase val (123 2) (t 1)))) (ert-info ((prin1-to-string form) :prefix "Form: ") - (let ((error (should-error (macroexpand form)))) - (should (equal (cdr error) - '("Misplaced t or `otherwise' clause")))))))) + (let ((error (should-error (macroexpand form)))) + (should (equal (cdr error) + '("Misplaced t or `otherwise' clause")))))))) (ert-deftest cl-case-warning () "Test that `cl-case' and `cl-ecase' warn about suspicious @@ -833,10 +908,10 @@ cl-case-warning (dolist (macro '(cl-case cl-ecase)) (let ((form `(,macro val (,case 1)))) (ert-info ((prin1-to-string form) :prefix "Form: ") - (ert-with-message-capture messages - (macroexpand form) - (should (equal messages - (concat "Warning: " message "\n")))))))))) + (ert-with-message-capture messages + (macroexpand form) + (should (equal messages + (concat "Warning: " message "\n")))))))))) (ert-deftest cl-case-no-warning () "Test that `cl-case' and `cl-ecase' don't warn in some valid cases. @@ -875,4 +950,45 @@ cl-defstruct-dynbound-label-47552 (should (equal (cl--test-s-cl--test-a x) 4)) (should (equal (cl--test-s-b x) 'dyn))))) +(ert-deftest cl-lib-keyword-names-versus-values () + (should (equal + (funcall (cl-function (lambda (&key a b) (list a b))) + :b :a :a 42) + '(42 :a)))) + +(ert-deftest cl-lib-empty-keyargs () + (should-error (funcall (cl-function (lambda (&key) 1)) + :b 1))) + +(ert-deftest cl-lib-test-gensym () + ;; Since the expansion of `should' calls `cl-gensym' and thus has a + ;; side-effect on `cl--gensym-counter', we have to make sure all + ;; macros in our test body are expanded before we rebind + ;; `cl--gensym-counter' and run the body. Otherwise, the test would + ;; fail if run interpreted. + (let ((body (byte-compile + '(lambda () + (should (equal (symbol-name (cl-gensym)) "G0")) + (should (equal (symbol-name (cl-gensym)) "G1")) + (should (equal (symbol-name (cl-gensym)) "G2")) + (should (equal (symbol-name (cl-gensym "foo")) "foo3")) + (should (equal (symbol-name (cl-gensym "bar")) "bar4")) + (should (equal cl--gensym-counter 5)))))) + (let ((cl--gensym-counter 0)) + (funcall body)))) + +(ert-deftest cl-the () + (should (eql (cl-the integer 42) 42)) + (should-error (cl-the integer "abc")) + (let ((side-effect 0)) + (should (= (cl-the integer (cl-incf side-effect)) 1)) + (should (= side-effect 1)))) + +(ert-deftest cl-lib-test-typep () + (cl-deftype cl-lib-test-type (&optional x) `(member ,x)) + ;; Make sure we correctly implement the rule that deftype's optional args + ;; default to `*' rather than to nil. + (should (cl-typep '* 'cl-lib-test-type)) + (should-not (cl-typep 1 'cl-lib-test-type))) + ;;; cl-macs-tests.el ends here diff --git a/test/lisp/emacs-lisp/cl-seq-tests.el b/test/lisp/emacs-lisp/cl-seq-tests.el index 97276be3870..2348a7fc812 100644 --- a/test/lisp/emacs-lisp/cl-seq-tests.el +++ b/test/lisp/emacs-lisp/cl-seq-tests.el @@ -22,7 +22,7 @@ ;;; Code: (require 'ert) -(require 'cl-seq) +(require 'cl-lib) (ert-deftest cl-union-test-00 () "Test for bug#22729." @@ -54,8 +54,10 @@ cl-seq-tests--relet* (ert-deftest cl-seq-endp-test () (should (cl-endp '())) - (should (not (cl-endp '(1 2 3)))) - (should-error (cl-endp 42) :type 'wrong-type-argument)) + (should-not (cl-endp '(1))) + (should-not (cl-endp '(1 2 3))) + (should-error (cl-endp 1) :type 'wrong-type-argument) + (should-error (cl-endp [1]) :type 'wrong-type-argument)) (ert-deftest cl-seq-reduce-test () (should (equal 6 (cl-reduce #'+ '(1 2 3)))) @@ -97,6 +99,37 @@ cl-seq-replace-test (should (equal '(1 2 a a 5 2 6) (cl-replace l1 l2 :start1 2 :end1 4))) (should (equal '(a a 3 4 5 2 6) (cl-replace l1 l2 :start2 2 :end2 4))))) +(ert-deftest cl-lib-test-remove () + (let ((list (list 'a 'b 'c 'd)) + (key-index 0) + (test-index 0)) + (let ((result + (cl-remove 'foo list + :key (lambda (x) + (should (eql x (nth key-index list))) + (prog1 + (list key-index x) + (cl-incf key-index))) + :test + (lambda (a b) + (should (eql a 'foo)) + (should (equal b (list test-index + (nth test-index list)))) + (cl-incf test-index) + (member test-index '(2 3)))))) + (should (equal key-index 4)) + (should (equal test-index 4)) + (should (equal result '(a d))) + (should (equal list '(a b c d))))) + (let ((x (cons nil nil)) + (y (cons nil nil))) + (should (equal (cl-remove x (list x y)) + ;; or (list x), since we use `equal' -- the + ;; important thing is that only one element got + ;; removed, this proves that the default test is + ;; `eql', not `equal' + (list y))))) + ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-remove-test () (let ((list '(1 2 3 4 5 2 6))) @@ -122,6 +155,20 @@ cl-remove-if-test (should (equal '() (cl-remove-if #'cl-evenp '()))) (should (equal '() (cl-remove-if #'cl-evenp '(2))))) +(ert-deftest cl-lib-test-remove-if-not () + (let ((list (list 'a 'b 'c 'd)) + (i 0)) + (let ((result (cl-remove-if-not (lambda (x) + (should (eql x (nth i list))) + (cl-incf i) + (member i '(2 3))) + list))) + (should (equal i 4)) + (should (equal result '(b c))) + (should (equal list '(a b c d))))) + (should (equal '() + (cl-remove-if-not (lambda (_x) (should nil)) '())))) + (ert-deftest cl-remove-if-not-test () (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4)))) (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :count 2))) @@ -309,6 +356,14 @@ cl-seq-nsubstitute-test (let ((pred (lambda (x) (> (cl-position x orig :from-end t) 1)))) (should (equal '(b 2 3 4 5 2 6) (cl-nsubstitute 'b nil l :if-not pred)))))) +(ert-deftest cl-lib-test-string-position () + (should (eql (cl-position ?x "") nil)) + (should (eql (cl-position ?a "abc") 0)) + (should (eql (cl-position ?b "abc") 1)) + (should (eql (cl-position ?c "abc") 2)) + (should (eql (cl-position ?d "abc") nil)) + (should (eql (cl-position ?A "abc") nil))) + ;; keywords supported: :test :test-not :key :start :end :from-end (ert-deftest cl-seq-position-test () (let ((list '(1 2 3 4 5 2 6))) @@ -401,6 +456,14 @@ cl-count-if-not-test '(1 2 3 4 5 6)))) (should (equal result 2)))) +(ert-deftest cl-lib-test-mismatch () + (should (eql (cl-mismatch "" "") nil)) + (should (eql (cl-mismatch "" "a") 0)) + (should (eql (cl-mismatch "a" "a") nil)) + (should (eql (cl-mismatch "ab" "a") 1)) + (should (eql (cl-mismatch "Aa" "aA") 0)) + (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) + ;; keywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end (ert-deftest cl-seq-mismatch-test () (let ((list '(1 2 3 4 5 2 6)) @@ -776,6 +839,57 @@ cl-rassoc-if-not-test '(((1 2) . 1) ((3 4) . 2) ((5) . 2))))) (should (equal result '((1 2) . 1))))) +(ert-deftest cl-lib-test-set-functions () + (let ((c1 (cons nil nil)) + (c2 (cons nil nil)) + (sym (make-symbol "a"))) + (let ((e '()) + (a (list 'a 'b sym nil "" "x" c1 c2)) + (b (list c1 'y 'b sym 'x))) + (should (equal (cl-set-difference e e) e)) + (should (equal (cl-set-difference a e) a)) + (should (equal (cl-set-difference e a) e)) + (should (equal (cl-set-difference a a) e)) + (should (equal (cl-set-difference b e) b)) + (should (equal (cl-set-difference e b) e)) + (should (equal (cl-set-difference b b) e)) + ;; Note: this test (and others) is sensitive to the order of the + ;; result, which is not documented. + (should (equal (cl-set-difference a b) (list 'a nil "" "x" c2))) + (should (equal (cl-set-difference b a) (list 'y 'x))) + + ;; We aren't testing whether this is really using `eq' rather than `eql'. + (should (equal (cl-set-difference e e :test 'eq) e)) + (should (equal (cl-set-difference a e :test 'eq) a)) + (should (equal (cl-set-difference e a :test 'eq) e)) + (should (equal (cl-set-difference a a :test 'eq) e)) + (should (equal (cl-set-difference b e :test 'eq) b)) + (should (equal (cl-set-difference e b :test 'eq) e)) + (should (equal (cl-set-difference b b :test 'eq) e)) + (should (equal (cl-set-difference a b :test 'eq) (list 'a nil "" "x" c2))) + (should (equal (cl-set-difference b a :test 'eq) (list 'y 'x))) + + (should (equal (cl-union e e) e)) + (should (equal (cl-union a e) a)) + (should (equal (cl-union e a) a)) + (should (equal (cl-union a a) a)) + (should (equal (cl-union b e) b)) + (should (equal (cl-union e b) b)) + (should (equal (cl-union b b) b)) + (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) + + (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) + + (should (equal (cl-intersection e e) e)) + (should (equal (cl-intersection a e) e)) + (should (equal (cl-intersection e a) e)) + (should (equal (cl-intersection a a) a)) + (should (equal (cl-intersection b e) e)) + (should (equal (cl-intersection e b) e)) + (should (equal (cl-intersection b b) b)) + (should (equal (cl-intersection a b) (list sym 'b c1))) + (should (equal (cl-intersection b a) (list sym 'b c1)))))) + (ert-deftest cl-intersection-test () (let ((result (cl-intersection '(1 2 3 4) '(3 4 5 6)))) (should (equal result '(4 3)))) @@ -815,8 +929,10 @@ cl-nintersection-test '(1 2 3)))) (ert-deftest cl-set-difference-test () - (let ((result (cl-set-difference '(1 2 3 4) '(3 4 5 6)))) - (should (equal result '(1 2)))) + ;; Our set-difference preserves order, though it is not required to + ;; by CL standards. Nevertheless better keep that invariant. + (should (equal (cl-set-difference '(1 2 3 4) '(3 4 5 6)) + '(1 2))) (let ((result (cl-set-difference '(1 2 3) '()))) (should (equal result '(1 2 3)))) (let ((result (cl-set-difference '(1 2 3) '(1 2 3)))) @@ -843,6 +959,33 @@ cl-set-difference-test (should (equal list1 '(1 2 3))) (should (equal list2 '(2 3 4))))) +(ert-deftest cl-nset-difference () + ;; Our nset-difference doesn't preserve order. + (let* ((l1 (list 1 2 3 4)) (l2 '(3 4 5 6)) + (diff (cl-nset-difference l1 l2))) + (should (memq 1 diff)) + (should (memq 2 diff)) + (should (= (length diff) 2)) + (should (equal l2 '(3 4 5 6)))) + (let* ((l1 (list "1" "2" "3" "4")) (l2 '("3" "4" "5" "6")) + (diff (cl-nset-difference l1 l2 :test #'equal))) + (should (member "1" diff)) + (should (member "2" diff)) + (should (= (length diff) 2)) + (should (equal l2 '("3" "4" "5" "6")))) + (let* ((l1 (list '(a . 1) '(b . 2) '(c . 3) '(d . 4))) + (l2 (list '(c . 3) '(d . 4) '(e . 5) '(f . 6))) + (diff (cl-nset-difference l1 l2 :key #'car))) + (should (member '(a . 1) diff)) + (should (member '(b . 2) diff)) + (should (= (length diff) 2))) + (let* ((l1 (list '("a" . 1) '("b" . 2) '("c" . 3) '("d" . 4))) + (l2 (list '("c" . 3) '("d" . 4) '("e" . 5) '("f" . 6))) + (diff (cl-nset-difference l1 l2 :key #'car :test #'string=))) + (should (member '("a" . 1) diff)) + (should (member '("b" . 2) diff)) + (should (= (length diff) 2)))) + (ert-deftest cl-nset-difference-test () (should-not (cl-nset-difference () ())) (should-not (cl-nset-difference () (list 1 2 3))) -- 2.47.2 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 11 Feb 2025 07:44:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 11 02:44:10 2025 Received: from localhost ([127.0.0.1]:54145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1thkwE-0006fk-DL for submit <at> debbugs.gnu.org; Tue, 11 Feb 2025 02:44:10 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:52583) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1thkwB-0006fG-9Z for 75633 <at> debbugs.gnu.org; Tue, 11 Feb 2025 02:44:08 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-aaedd529ba1so647820966b.1 for <75633 <at> debbugs.gnu.org>; Mon, 10 Feb 2025 23:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739259841; x=1739864641; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=eMlKZgPDdVLzRdMYfPOJaLhnqJx/MvSGBRuYvQDWb6M=; b=F8+oWWABt8jjAXFd8K1roKj67Q0oda+FvXCj6yuPD5Iw+/L69e/h3ybPd6nQl14v5p V05pbv2qqNcmfeq34S1vP8ee3SQsaUFXjyTcMu5Qqgs28UDwcKJf5ApCev0tcobkLCkt ZxrQLoC1BSFMJjdoMh3TyGm4x//6kj9Xe00VaUA9wEPYVOPeUIf8wTgLLzbndxR3+1bw wl/iPYyjPCjyWg/Z0MY7T6o11r1QwbmpdGXAddiMqYYNJrJH9mJnjHB3bxwvXlWvWjRc tJZq6NBqtJJiMPRRIN3DxJPQff/FW7v/ttpvWoOlWMQGAaN+rrd1/3tmeE2xec3kcFdX 90Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739259841; x=1739864641; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eMlKZgPDdVLzRdMYfPOJaLhnqJx/MvSGBRuYvQDWb6M=; b=P/LPLqGaEwXlNRsmnYGvdIA/gBotxirSKXvpKoPAypA6xTE1hBYGtZmJjwR6IEQk4j XPhY5eNSjdoI3FPdtCyLJbNtI/mYQt9fPNqN2ZRwwVvFxDFYO3kzUyqFeAQ0mbFvvm6l ToL2qQT1nvpN/PRfLSPadj8wQSnJpFBv7zUX7uzudIPzeHWhDKaW7Enh7VvkjAhOeZut shoIoQoAQ3utHnEKhj0NL8mtF5VrU56VjYZo9G8YcaDu5ESwNF1eCGz10m3gk8EZWCnF ySlHpkwRjf985cVt9zgUNHLl4vD3Z6c5y1n0EBYrJL9mVnXGqC45nmbQFcgZc4m1RKm+ EfMA== X-Forwarded-Encrypted: i=1; AJvYcCXnsmihjGss+2rAmpoRJOhguAzYbfFDIsVxdD3Sk//VeXufdjDzHwd2hYXI3V/rJCeojw7gcg==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyMIYvY6oNeX4AXVrA1PxUEz8vqaK/hv+eQVLdljLOqO33GTQOJ vQ0czEkXdcjVRcYbXqf74Ro4QUleyHAbuC2hVuWtlsGtVQqWnTlgdF2rnG9thWGuKKqDToFXLjC 1rC+Ad3yyiehCcvGVLuHzK1oau9k= X-Gm-Gg: ASbGnct0wAIKjB9CW9Wgu0rvc6hG+w4vTE4buOIRUi9G+9pkGx/K3SQRpOq2fTM3ttW 5++VJ22boYOZKWZalSO3w/m0iA/wmKOwFzda53ZHaHI9Uy4FwdmxZ5D0vFg3B/WhZkgz2bx6sGA == X-Google-Smtp-Source: AGHT+IFIh4taMI8N7dvfzVFGtZFFI0unJQHqNRfEZR/Qepb19aFd5neO8jBG2D3WzPykEssa7FsskqfjfBAZg4UcGvQ= X-Received: by 2002:a05:6402:210e:b0:5dc:58c8:3154 with SMTP id 4fb4d7f45d1cf-5de450800a4mr47541736a12.28.1739259837536; Mon, 10 Feb 2025 23:43:57 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 10 Feb 2025 23:43:56 -0800 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <87r04qn2t0.fsf@HIDDEN> References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> <87r04qn2t0.fsf@HIDDEN> MIME-Version: 1.0 Date: Mon, 10 Feb 2025 23:43:56 -0800 X-Gm-Features: AWEUYZm2Gix4mzhW-dTW8TGoAGKC8aNr2F61AVb2WRVmoMRj0_PKTyjbRDWRNrY Message-ID: <CADwFkmn-nPRTHAS0TUkduhit2AbL0+fd1QgST4F6RF2dBBBWbQ@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib To: "Basil L. Contovounesios" <basil@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75633 Cc: eliz@HIDDEN, Ahmed Khanzada <me@HIDDEN>, 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) "Basil L. Contovounesios" <basil@HIDDEN> writes: > I would like to apply it if there are no objections; otherwise feel free > to use/adapt it as desired. Thanks for working on this. Can we please apply your patch now? It would be nice not to have to see those warnings from the tests.
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 25 Jan 2025 18:53:25 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 25 13:53:25 2025 Received: from localhost ([127.0.0.1]:52615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tblHV-0008Bh-F1 for submit <at> debbugs.gnu.org; Sat, 25 Jan 2025 13:53:25 -0500 Received: from mta-11-4.privateemail.com ([198.54.127.104]:52983) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <basil@HIDDEN>) id 1tblHP-0008BE-AC for 75633 <at> debbugs.gnu.org; Sat, 25 Jan 2025 13:53:19 -0500 Received: from mta-11.privateemail.com (localhost [127.0.0.1]) by mta-11.privateemail.com (Postfix) with ESMTP id 4YgP2W2FRNz3hhTy; Sat, 25 Jan 2025 13:53:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=contovou.net; s=default; t=1737831187; bh=Z46+aAoW+BRcBAOeO9PDPXbTGQ9rG6jzEM20cFFffLc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=rWgVyKztfXl5MmbOGPy2b5yIRWEb9v25X7QMquBkOnNTn7STNOkaRPaKnIkut+bbb 5aEIAFhgO4lrUP0r0hWm2N2+jRZRq+/Ym8fuR90ljxR8Yx8ACnRzBHfJcyDSMT7NI6 q0epf9+W5LarElFoMgGUVjFSY05cvlOXbV5bwZFF865KDXDLymauAIYsDLBMxnAqwS hMXNPYnJfvEV1UrKnpnT3lnRHPDaPMmnk6fIYvkiK+Mgd9UC6STWDv4GtyYRiLmY69 /oSwk8WB6OEAXg5y4lEdo3vDO28JesB+8VBKthBu1lznu47E5wvpayRKfzhUtsFm9F RD0QRDpL8n8Sw== Received: from localhost (unknown [31.46.245.107]) by mta-11.privateemail.com (Postfix) with ESMTPA; Sat, 25 Jan 2025 13:53:04 -0500 (EST) From: "Basil L. Contovounesios" <basil@HIDDEN> To: Ahmed Khanzada <me@HIDDEN> Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib In-Reply-To: <8734hgjjb4.fsf@HIDDEN> (Ahmed Khanzada's message of "Sat, 18 Jan 2025 09:19:43 -0500") References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> <8734hgjjb4.fsf@HIDDEN> Date: Sat, 25 Jan 2025 19:52:59 +0100 Message-ID: <87r04qn2t0.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75633 Cc: eliz@HIDDEN, 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Ahmed Khanzada [2025-01-17 09:52 -0500] wrote: > Subject: [PATCH] New unit-tests for cl-lib Thank you for improving the test suite! I include some comments, nits, and a patch below. Ahmed Khanzada [2025-01-18 09:19 -0500] wrote: > Yes, I will look into the cl-seq-tests byecompiling warnings and fix them. The warnings drew my attention to several preexisting bugs in cl-seq-tests.el, with us since bug#24264. For example, none of the tests using cl-seq--with-side-effects were actually being evaluated. I thus took the liberty of scrutinising the file a bit closer and attach the resulting patch. I would like to apply it if there are no objections; otherwise feel free to use/adapt it as desired. > + (should (equal '(2) (cl-remove-if-not 'evenp '(2) :key #'(lambda (x) (- x)))))) ^^^^^^^^^^^^^^^^^^^^ AKA #'-. Also, there is no need to #'-quote lambdas, as they are self-quoting. > +(ert-deftest cl-delete-if-test () > + (let ((list (list 1 2 3 4 5))) Only used once, and unlike the remaining test cases which use no variable. > + (cl-delete-if 'evenp list) It's more robust to check the return value of deletion functions, rather than rely on their side effects. This would also pacify the byte-compiler warning. > +(ert-deftest cl-delete-if-not-test () > + (let ((list (list 1 2 3 4 5))) Ditto re: gratuitous binding. > + (let ((result (cl-substitute-if 'x #'(lambda (n) t) '(1 2 3 4 5)))) ^^^^^^^^^^^^^^^^ AKA (lambda (_) t) or #'always. This would also pacify the byte-compiler. > + (let ((result (cl-count-if (lambda (x) nil) '(1 2 3 4)))) ^^^^^^^^^^^^^^^^ AKA (lambda (_) nil) or (lambda (_)) or #'ignore. This would also pacify the byte-compiler. > +(ert-deftest cl-sort-test () > + (let ((result (cl-sort '(3 1 4 1 5 9 2 6 5 3 5) '<))) cl-sort and cl-stable-sort are documented as being destructive functions, so it's unsafe to pass them an 'immutable' quoted literal; for details see (info "(elisp) Mutability"). Passing a fresh list would also pacify the byte-compiler. > + (let ((result (cl-sort '("banana" "fig" "apple" "kiwi") (lambda (x y) (< (length x) (length y))) :key 'identity))) This and other lines are slightly long. > + (let ((result (cl-sort (vector 3 1 4 1 5) '<))) > + (should (equal result (vector 1 1 3 4 5)))) While the argument to cl-sort ought to be fresh/mutable, its result can safely be compared to a quoted value such as [1 1 3 4 5]. > +(ert-deftest cl-merge-test () > + (let ((result (cl-merge 'list '(1 3 5) '(2 4 6) '<))) Ditto re: passing a fresh value to cl-merge, which is destructive. > + (let ((result (cl-member-if #'(lambda (x) (< x 0)) '(1 2 3 4 5)))) ^^^^^^^^^^^^^^^^^^^^^^ AKA #'cl-minusp. > + (let ((result (cl-assoc-if-not #'(lambda (x) (> x 0)) '((1 . "one") (2 . "two") (3 . "three"))))) ^^^^^^^^^^^^^^^^^^^^^^ AKA #'cl-plusp. > + (let ((result (cl-intersection '(1 "two" 3) '(3 "two" 4)))) > + (should (equal result '(3)))) This assumes (not (eql "two" "two")), which I'm not sure can always be guaranteed in the face of optimisations. I would replace at least one of the string literals with a fresh one. > +(ert-deftest cl-nintersection-test () > + (let ((list1 '(1 2 3 4)) > + (list2 '(3 4 5 6))) > + (let ((result (cl-nintersection list1 list2))) Ditto re: passing fresh values to cl-nintersection, which is a destructive function. > + (should (equal list1 '(1 2 3 4))) > + (should (equal list2 '(3 4 5 6))))) This seems dubious: list1 and list2 are quoted literals which may have been modified by side effect. Besides, the docstring of cl-nintersection (and other destructive functions) explicitly claims to modify its arguments, so I don't understand why we would want to check that they remain unmodified. > + (let ((list1 '(1 "two" 3)) > + (list2 '(3 "two" 4))) > + (let ((result (cl-nintersection list1 list2))) Ditto re: assuming (not (eql "two" "two")) always holds. > + (let ((result (cl-set-difference '((1 . "one") (2 . "two") (3 . "three")) > + '((1 . "uno") (2 . "dos")) > + :key 'car))) Indentation. > + (let ((list1 '(1 2 3)) > + (list2 '(2 3 4))) > + (cl-set-difference list1 list2) > + (should (equal list1 '(1 2 3))) > + (should (equal list2 '(2 3 4))))) This assumes that modifying the literal '(1 2 3) in the list1 argument's value will not also modify the same literal in the subsequent (equal list1 '(1 2 3)), which I'm not sure is robust in the face of optimisations (and similarly for list2). To detect (the absence of) modification, I would use fresh arguments. It also doesn't hurt to check the return value of cl-set-difference, which would pacify the byte-compiler. > +(ert-deftest cl-nset-difference-test () > + (let ((list1 '(1 2 3 4)) > + (list2 '(3 4 5 6))) > + (let ((result (cl-nset-difference list1 list2))) Ditto re: passing fresh values to cl-nset-difference, which is a destructive function. > + (let ((result (cl-set-exclusive-or '(1 2 3 4 5) '(3 4 5 6 7))) > + (list1 '(1 2 3 4 5)) > + (list2 '(3 4 5 6 7))) > + (should (equal result '(1 2 6 7))) > + (should (equal list1 '(1 2 3 4 5))) > + (should (equal list2 '(3 4 5 6 7))))) Ditto re: detecting modifications to quoted literals. More importantly, list1 and list2 are not actually used. > +(ert-deftest cl-nset-exclusive-or-test () > + (let ((list1 '(1 2 3)) > + (list2 '(3 4 5))) > + (let ((result (cl-nset-exclusive-or list1 list2))) Ditto re: passing fresh values to cl-nset-exclusive-or, which is a destructive function. > +(ert-deftest cl-subsetp-test () > + (let ((result (cl-subsetp '(1 2) '(1 2 3 4)))) > + (should (equal result t))) The docstring of cl-subsetp mentions a 'true' return value, and its entry in the manual says nothing about the return value. While 'true' generally means t, in the absence of a stronger indication I would just accept any non-nil return value here. > +(ert-deftest cl-lib-set-difference () > +(ert-deftest cl-nset-difference () Why are there tests for cl-set-difference and cl-nset-difference in both cl-lib-tests.el and cl-seq-tests.el? Thanks, -- Basil --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-cl-seq-tests.el.patch From 8df661683c61c93661a93ff9997e9aa0da990f3e Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" <basil@HIDDEN> Date: Sat, 25 Jan 2025 16:48:19 +0100 Subject: [PATCH] Fix cl-seq-tests.el None of the tests using the macro cl-seq--with-side-effects were being evaluated (since bug#24264), and other tests were not robust against destructive operations or optimizations (since bug#24264 and bug#75633). * test/lisp/emacs-lisp/cl-seq-tests.el: Fit first line within 80 columns. Remove empty Commentary section. (cl-union-test-00): Use bug#N reference in place of URL. (cl-seq-test-bug24264): Ditto. Use nconc in place of append. (cl-seq--test-list, cl-seq--test-list2, cl-seq--with-side-effects): Remove. (cl-seq-tests--relet*): New convenience macro replacing the need for cl-seq--with-side-effects. (cl-seq-fill-test, cl-seq-replace-test, cl-seq-delete-test): Use cl-seq-tests--relet* to actually evaluate tests. Avoid mutating quoted literals. (cl-seq-nsubstitute-test): Ditto. Actually call cl-nsubstitute, not cl-substitute. Avoid comparing mutated argument to itself; compare to its original copy instead. Avoid calling cl-position on list that is being mutated in :if predicate; use original copy instead. (cl-seq-remove-test, cl-remove-if-not-test, cl-delete-if-not-test) (cl-delete-duplicates-test, cl-seq-remove-duplicates-test) (cl-seq-substitute-test, cl-seq-substitute-if-test) (cl-seq-position-test, cl-count-if-test, cl-count-if-not-test) (cl-member-if-test, cl-member-if-not-test, cl-assoc-if-test) (cl-assoc-if-not-test, cl-rassoc-if-test, cl-subsetp-test): Simplify. (cl-remove-if-test, cl-seq-substitute-if-not-test, cl-find-if-test) (cl-find-if-not-test, cl-position-if-test, cl-member-test) (cl-assoc-test, cl-rassoc-test): Quote function symbols, not lambdas. (cl-delete-if-test): Use cl-seq-tests--relet*. Check result of cl-delete-if to avoid relying on its side effects, and to pacify byte-compiler warning. (cl-seq-mismatch-test): Avoid 'easy to misread' hidden argument. (cl-seq-search-test): Break long line. (cl-sort-test, cl-stable-sort-test, cl-merge-test): Avoid mutating quoted literals. (cl-intersection-test): Avoid comparing eql-ity of string literals. (cl-nintersection-test, cl-nset-difference-test) (cl-nset-exclusive-or-test): Avoid mutating quoted literals. Don't compare initial and final values of arguments, since they may have been mutated. (cl-set-difference-test, cl-set-exclusive-or-test): Use fresh arguments to check for absence of mutation. --- test/lisp/emacs-lisp/cl-seq-tests.el | 898 ++++++++++++--------------- 1 file changed, 401 insertions(+), 497 deletions(-) diff --git a/test/lisp/emacs-lisp/cl-seq-tests.el b/test/lisp/emacs-lisp/cl-seq-tests.el index 3541a989d34..97276be3870 100644 --- a/test/lisp/emacs-lisp/cl-seq-tests.el +++ b/test/lisp/emacs-lisp/cl-seq-tests.el @@ -1,4 +1,4 @@ -;;; cl-seq-tests.el --- Tests for cl-seq.el functionality -*- lexical-binding: t; -*- +;;; cl-seq-tests.el --- Tests for cl-seq.el -*- lexical-binding: t; -*- ;; Copyright (C) 2015-2025 Free Software Foundation, Inc. @@ -19,15 +19,13 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. -;;; Commentary: - ;;; Code: (require 'ert) (require 'cl-seq) (ert-deftest cl-union-test-00 () - "Test for https://debbugs.gnu.org/22729 ." + "Test for bug#22729." (let ((str1 "foo") (str2 (make-string 3 ?o))) ;; Emacs may make two string literals eql when reading. @@ -36,28 +34,23 @@ cl-union-test-00 (should (equal str1 str2)) (should (equal (cl-union (list str1) (list str2)) (list str2))) - (should (equal (cl-union (list str1) (list str2) :test 'eql) + (should (equal (cl-union (list str1) (list str2) :test #'eql) (list str1 str2))))) -(defvar cl-seq--test-list nil - "List used on `cl-seq' tests with side effects.") -(defvar cl-seq--test-list2 nil - "List used on `cl-seq' tests with side effects.") - -(defmacro cl-seq--with-side-effects (list list2 &rest body) - "Run a test with side effects on lists; after the test restore the lists. -LIST is the value of `cl-seq--test-list' before the test. -LIST2, if non-nil, is the value of `cl-seq--test-list2' before the test. -Body are forms defining the test." - (declare (indent 2) (debug t)) - (let ((orig (make-symbol "orig")) - (orig2 (make-symbol "orig2"))) - `(let ((,orig (copy-sequence ,list)) - (,orig2 (copy-sequence ,list2))) - (unwind-protect (progn ,@body) - (setq cl-seq--test-list ,orig) - (when ,list2 - (setq cl-seq--test-list2 ,orig2)))))) +(defmacro cl-seq-tests--relet* (binders &rest body) + "Like `let*', but reevaluate BINDERS before each form in BODY. +Additionally register an `ert-info' to help identify test failures." + (declare (debug let) (indent 1)) + (let ((syms (mapcar (lambda (binder) + (if (consp binder) (car binder) binder)) + binders))) + (macroexp-progn + (mapcar (lambda (form) + `(ert-info (,(lambda () (pp-to-string form)) :prefix "form: ") + (let* ,binders + ,@(and syms `((ignore ,@syms))) + ,form))) + body)))) (ert-deftest cl-seq-endp-test () (should (cl-endp '())) @@ -77,51 +70,39 @@ cl-seq-reduce-test ;; keywords supported: :start :end (ert-deftest cl-seq-fill-test () - (let* ((cl-seq--test-list '(1 2 3 4 5 2 6)) - (orig (copy-sequence cl-seq--test-list)) - (tests '((should (equal '(b b b b b b b) (cl-fill _list 'b))) - (should (equal '(1 2 3 4 b b b) (cl-fill _list 'b :start 4))) - (should (equal '(b b b b 5 2 6) (cl-fill _list 'b :end 4))) - (should (equal '(1 2 b b 5 2 6) (cl-fill _list 'b :start 2 :end 4))) - (should (equal orig (cl-fill _list 'b :end 0)))))) - (dolist (test tests) - (let ((_list cl-seq--test-list)) - (cl-seq--with-side-effects orig nil - test))))) + (cl-seq-tests--relet* ((l (list 1 2 3 4 5 2 6)) + (orig (copy-sequence l))) + (should (equal '(b b b b b b b) (cl-fill l 'b))) + (should (equal '(1 2 3 4 b b b) (cl-fill l 'b :start 4))) + (should (equal '(b b b b 5 2 6) (cl-fill l 'b :end 4))) + (should (equal '(1 2 b b 5 2 6) (cl-fill l 'b :start 2 :end 4))) + (should (equal orig (cl-fill l 'b :end 0))))) ;; keywords supported: :start1 :end1 :start2 :end2 (ert-deftest cl-seq-replace-test () - (let* ((cl-seq--test-list '(1 2 3 4 5 2 6)) - (cl-seq--test-list2 (make-list 6 'a)) - (orig (copy-sequence cl-seq--test-list)) - (orig2 (copy-sequence cl-seq--test-list2)) - (tests '((should (equal '(a a a a a a 6) (cl-replace _list _list2))) - (should (equal '(a a a a a a 6) (cl-replace _list _list2 :start1 0))) - (should (equal '(a a a a a a 6) (cl-replace _list _list2 :start2 0))) - (should (equal orig (cl-replace _list _list2 :start1 (length _list)))) - (should (equal orig (cl-replace _list _list2 :start2 (length _list2)))) - (should (equal orig (cl-replace _list _list2 :end1 0))) - (should (equal orig (cl-replace _list _list2 :end2 0))) - (should (equal '(1 2 3 4 a a a) (cl-replace _list _list2 :start1 4))) - (should (equal '(a a a a 5 2 6) (cl-replace _list _list2 :end1 4))) - (should (equal '(a a 3 4 5 2 6) (cl-replace _list _list2 :start2 4))) - (should (equal '(a a a a 5 2 6) (cl-replace _list _list2 :end2 4))) - (should (equal '(1 2 a a 5 2 6) (cl-replace _list _list2 :start1 2 :end1 4))) - (should (equal '(a a 3 4 5 2 6) (cl-replace _list _list2 :start2 2 :end2 4)))))) - (dolist (test tests) - (let ((_list cl-seq--test-list) - (_list2 cl-seq--test-list2)) - (cl-seq--with-side-effects orig orig2 - test))))) + (cl-seq-tests--relet* ((l1 (list 1 2 3 4 5 2 6)) + (l2 (make-list 6 'a)) + (orig1 (copy-sequence l1))) + (should (equal '(a a a a a a 6) (cl-replace l1 l2))) + (should (equal '(a a a a a a 6) (cl-replace l1 l2 :start1 0))) + (should (equal '(a a a a a a 6) (cl-replace l1 l2 :start2 0))) + (should (equal orig1 (cl-replace l1 l2 :start1 (length l1)))) + (should (equal orig1 (cl-replace l1 l2 :start2 (length l2)))) + (should (equal orig1 (cl-replace l1 l2 :end1 0))) + (should (equal orig1 (cl-replace l1 l2 :end2 0))) + (should (equal '(1 2 3 4 a a a) (cl-replace l1 l2 :start1 4))) + (should (equal '(a a a a 5 2 6) (cl-replace l1 l2 :end1 4))) + (should (equal '(a a 3 4 5 2 6) (cl-replace l1 l2 :start2 4))) + (should (equal '(a a a a 5 2 6) (cl-replace l1 l2 :end2 4))) + (should (equal '(1 2 a a 5 2 6) (cl-replace l1 l2 :start1 2 :end1 4))) + (should (equal '(a a 3 4 5 2 6) (cl-replace l1 l2 :start2 2 :end2 4))))) ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-remove-test () (let ((list '(1 2 3 4 5 2 6))) (should (equal list (cl-remove 'foo list))) - (should (equal '(1 3 4 5 6) (cl-remove 2 list))) - (should (equal '(1 3 4 5 6) (cl-remove 2 list - :key #'identity - :test (lambda (a b) (eql a b))))) + (should (equal '(1 3 4 5 6) (cl-remove 2 list))) + (should (equal '(1 3 4 5 6) (cl-remove 2 list :key #'identity :test #'eql))) (should (equal '(1 2 3 4 2) (cl-remove 4 list :test (lambda (a b) (> b a))))) (should (equal '(5 6) (cl-remove 4 list :test-not (lambda (a b) (> b a))))) (should (equal '(1 3 5) (cl-remove 'foo list :if #'cl-evenp))) @@ -133,67 +114,58 @@ cl-seq-remove-test (should (equal '(1 2 3 4 5 6) (cl-remove 2 list :from-end t :count 1))))) (ert-deftest cl-remove-if-test () - (should (equal '(1 3) (cl-remove-if 'cl-evenp '(1 2 3 4)))) - (should (equal '(1 3) (cl-remove-if 'cl-evenp '(1 2 3 4) :count 2))) - (should (equal '(1 3 4) (cl-remove-if 'cl-evenp '(1 2 3 4) :start 1 :end 3))) - (should (equal '(1 3) (cl-remove-if 'cl-evenp '(1 2 3 4) :from-end t))) - (should (equal '(2 4) (cl-remove-if 'cl-oddp '(1 2 3 4)))) - (should (equal '() (cl-remove-if 'cl-evenp '()))) - (should (equal '() (cl-remove-if 'cl-evenp '(2))))) + (should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4)))) + (should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4) :count 2))) + (should (equal '(1 3 4) (cl-remove-if #'cl-evenp '(1 2 3 4) :start 1 :end 3))) + (should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4) :from-end t))) + (should (equal '(2 4) (cl-remove-if #'cl-oddp '(1 2 3 4)))) + (should (equal '() (cl-remove-if #'cl-evenp '()))) + (should (equal '() (cl-remove-if #'cl-evenp '(2))))) (ert-deftest cl-remove-if-not-test () - (should (equal '(2 4) (cl-remove-if-not 'cl-evenp '(1 2 3 4)))) - (should (equal '(2 4) (cl-remove-if-not 'cl-evenp '(1 2 3 4) :count 2))) - (should (equal '(1 2 4) (cl-remove-if-not 'cl-evenp '(1 2 3 4) :start 1 :end 3))) - (should (equal '(2 4) (cl-remove-if-not 'cl-evenp '(1 2 3 4) :from-end t))) - (should (equal '(1 3) (cl-remove-if-not 'cl-oddp '(1 2 3 4)))) - (should (equal '() (cl-remove-if-not 'cl-evenp '()))) - (should (equal '(2) (cl-remove-if-not 'cl-evenp '(2)))) - (should (equal '(2) (cl-remove-if-not 'cl-evenp '(2) :key #'(lambda (x) (- x)))))) + (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4)))) + (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :count 2))) + (should (equal '(1 2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :start 1 :end 3))) + (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :from-end t))) + (should (equal '(1 3) (cl-remove-if-not #'cl-oddp '(1 2 3 4)))) + (should (equal '() (cl-remove-if-not #'cl-evenp '()))) + (should (equal '(2) (cl-remove-if-not #'cl-evenp '(2)))) + (should (equal '(2) (cl-remove-if-not #'cl-evenp '(2) :key #'-)))) ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-delete-test () - (let* ((cl-seq--test-list '(1 2 3 4 5 2 6)) - (orig (copy-sequence cl-seq--test-list)) - (tests '((should (equal orig (cl-delete 'foo _list))) - (should (equal '(1 3 4 5 6) (cl-delete 2 _list))) - (should (equal '(1 3 4 5 6) (cl-delete 2 _list - :key #'identity - :test (lambda (a b) (eql a b))))) - (should (equal '(1 2 3 4 2) (cl-delete 4 _list :test (lambda (a b) (> b a))))) - (should (equal '(5 6) (cl-delete 4 _list :test-not (lambda (a b) (> b a))))) - (should (equal '(1 3 5) (cl-delete 'foo _list :if #'cl-evenp))) - (should (equal '(2 4 2 6) (cl-delete 'foo _list :if-not #'cl-evenp))) - (should (equal '(1 2 3 4 5) (cl-delete 'foo _list :if #'cl-evenp :start 4))) - (should (equal '(1 2 3 4 5 6) (cl-delete 2 _list :start 5 :end 6))) - (should (equal '(1 3 4 5 2 6) (cl-delete 2 _list :count 1))) - (should (equal '(1 3 4 5 2 6) (cl-delete 2 _list :from-end nil :count 1))) - (should (equal '(1 2 3 4 5 6) (cl-delete 2 _list :from-end t :count 1)))))) - (dolist (test tests) - (let ((_list cl-seq--test-list)) - (cl-seq--with-side-effects orig nil - test))))) + (cl-seq-tests--relet* ((l (list 1 2 3 4 5 2 6)) + (orig (copy-sequence l))) + (should (equal orig (cl-delete 'foo l))) + (should (equal '(1 3 4 5 6) (cl-delete 2 l))) + (should (equal '(1 3 4 5 6) (cl-delete 2 l :key #'identity :test #'eql))) + (should (equal '(1 2 3 4 2) (cl-delete 4 l :test (lambda (a b) (> b a))))) + (should (equal '(5 6) (cl-delete 4 l :test-not (lambda (a b) (> b a))))) + (should (equal '(1 3 5) (cl-delete 'foo l :if #'cl-evenp))) + (should (equal '(2 4 2 6) (cl-delete 'foo l :if-not #'cl-evenp))) + (should (equal '(1 2 3 4 5) (cl-delete 'foo l :if #'cl-evenp :start 4))) + (should (equal '(1 2 3 4 5 6) (cl-delete 2 l :start 5 :end 6))) + (should (equal '(1 3 4 5 2 6) (cl-delete 2 l :count 1))) + (should (equal '(1 3 4 5 2 6) (cl-delete 2 l :from-end nil :count 1))) + (should (equal '(1 2 3 4 5 6) (cl-delete 2 l :from-end t :count 1))))) (ert-deftest cl-delete-if-test () - (let ((list (list 1 2 3 4 5))) - (cl-delete-if 'cl-evenp list) - (should (equal '(1 3 5) list)) - (should (equal '(1 3 5) (cl-delete-if 'cl-evenp (list 1 2 3 4 5) :start 0 :end 4))) - (should (equal '(1 3 5) (cl-delete-if 'cl-evenp (list 1 2 3 4 5) :from-end t))) - (should (equal '(2 4) (cl-delete-if 'cl-oddp (list 1 2 3 4 5)))) - (should (equal '() (cl-delete-if 'cl-evenp '()))) - (should (equal '() (cl-delete-if 'cl-evenp (list 2)))))) + (cl-seq-tests--relet* ((l (list 1 2 3 4 5))) + (should (equal '(1 3 5) (cl-delete-if #'cl-evenp l))) + (should (equal '(1 3 5) (cl-delete-if #'cl-evenp l :start 0 :end 4))) + (should (equal '(1 3 5) (cl-delete-if #'cl-evenp l :from-end t))) + (should (equal '(2 4) (cl-delete-if #'cl-oddp l)))) + (should (equal '() (cl-delete-if #'cl-evenp '()))) + (should (equal '() (cl-delete-if #'cl-evenp (list 2))))) (ert-deftest cl-delete-if-not-test () - (let ((list (list 1 2 3 4 5))) - (should (equal '(2 4) (cl-delete-if-not 'cl-evenp list))) - (should (equal '() (cl-delete-if-not 'cl-evenp '()))) - (should (equal '() (cl-delete-if-not 'cl-evenp (list 1)))))) + (should (equal '(2 4) (cl-delete-if-not #'cl-evenp (list 1 2 3 4 5)))) + (should (equal '() (cl-delete-if-not #'cl-evenp '()))) + (should (equal '() (cl-delete-if-not #'cl-evenp (list 1))))) (ert-deftest cl-delete-duplicates-test () - (let ((list (list 1 2 3 2 1))) - (should (equal '(3 2 1) (cl-delete-duplicates list))) - (should (equal '() (cl-delete-duplicates '()))))) + (should (equal '(3 2 1) (cl-delete-duplicates (list 1 2 3 2 1)))) + (should (equal '() (cl-delete-duplicates '())))) ;; keywords supported: :test :test-not :key :start :end :from-end (ert-deftest cl-seq-remove-duplicates-test () @@ -203,10 +175,10 @@ cl-seq-remove-duplicates-test (should (equal list (cl-remove-duplicates list :start 2))) (should (equal list (cl-remove-duplicates list :start 2 :from-end t))) (should (equal list (cl-remove-duplicates list :end 4))) - (should (equal '(6) (cl-remove-duplicates list :test (lambda (a b) (< a b))))) - (should (equal '(1 2 6) (cl-remove-duplicates list :test (lambda (a b) (>= a b))))) - (should (equal (cl-remove-duplicates list :test (lambda (a b) (>= a b))) - (cl-remove-duplicates list :test-not (lambda (a b) (< a b))))) + (should (equal '(6) (cl-remove-duplicates list :test #'<))) + (should (equal '(1 2 6) (cl-remove-duplicates list :test #'>=))) + (should (equal (cl-remove-duplicates list :test #'>=) + (cl-remove-duplicates list :test-not #'<))) (should (equal (cl-remove-duplicates list) (cl-remove-duplicates list :key #'number-to-string :test #'string=))) (should (equal list @@ -224,35 +196,38 @@ cl-seq-substitute-test (should (equal '(1 b 3 4 5 2 6) (cl-substitute 'b 2 list :count 1))) (should (equal '(1 2 3 4 5 b 6) (cl-substitute 'b 2 list :count 1 :from-end t))) (should (equal list (cl-substitute 'b 2 list :count -1))) - (should (equal '(1 b 3 4 5 b 6) (cl-substitute 'b "2" list :key #'number-to-string + (should (equal '(1 b 3 4 5 b 6) (cl-substitute 'b "2" list + :key #'number-to-string :test #'string=))) (should (equal (cl-substitute 'b 2 list) (cl-substitute 'b 2 list :test #'eq))) - (should (equal '(1 2 b b b 2 b) (cl-substitute 'b 2 list :test (lambda (a b) (< a b))))) - (should (equal '(b b 3 4 5 b 6) (cl-substitute 'b 2 list :test (lambda (a b) (>= a b))))) - (should (equal list (cl-substitute 'b 99 list :test (lambda (a b) (< a b))))) - (should (equal (cl-substitute 'b 2 list :test (lambda (a b) (>= a b))) - (cl-substitute 'b 2 list :test-not (lambda (a b) (< a b))))) - (should (equal '(1 2 b b b 2 b) (cl-substitute 'b nil list :if (lambda (x) (> (cl-position x list) 1))))) - (should (equal '(1 b b b b b b) (cl-substitute 'b nil list :if (lambda (x) (> (cl-position x list :from-end t) 1))))) - - (should (equal '(b b 3 4 5 b 6) (cl-substitute 'b nil list - :if-not (lambda (x) (> (cl-position x list) 1))))) - (should (equal '(b 2 3 4 5 2 6) (cl-substitute 'b nil list - :if-not (lambda (x) (> (cl-position x list :from-end t) 1))))))) + (should (equal '(1 2 b b b 2 b) (cl-substitute 'b 2 list :test #'<))) + (should (equal '(b b 3 4 5 b 6) (cl-substitute 'b 2 list :test #'>=))) + (should (equal list (cl-substitute 'b 99 list :test #'<))) + (should (equal (cl-substitute 'b 2 list :test #'>=) + (cl-substitute 'b 2 list :test-not #'<))) + (let ((pred (lambda (x) (> (cl-position x list) 1)))) + (should (equal '(1 2 b b b 2 b) (cl-substitute 'b nil list :if pred)))) + (let ((pred (lambda (x) (> (cl-position x list :from-end t) 1)))) + (should (equal '(1 b b b b b b) (cl-substitute 'b nil list :if pred)))) + (let ((pred (lambda (x) (> (cl-position x list) 1)))) + (should (equal '(b b 3 4 5 b 6) (cl-substitute 'b nil list :if-not pred)))) + (let ((pred (lambda (x) (> (cl-position x list :from-end t) 1)))) + (should (equal '(b 2 3 4 5 2 6) (cl-substitute 'b nil list :if-not pred)))))) (ert-deftest cl-seq-substitute-if-test () (let ((result (cl-substitute-if 'x #'cl-evenp '(1 2 3 4 5)))) (should (equal result '(1 x 3 x 5)))) (let ((result (cl-substitute-if 'x #'cl-evenp '(1 3 5)))) (should (equal result '(1 3 5)))) - (let ((result (cl-substitute-if 'x #'(lambda (n) t) '(1 2 3 4 5)))) + (let ((result (cl-substitute-if 'x #'always '(1 2 3 4 5)))) (should (equal result '(x x x x x)))) (let ((result (cl-substitute-if 'x #'cl-evenp '(1 2 3 4 5) :start 1 :end 4))) (should (equal result '(1 x 3 x 5)))) (let ((result (cl-substitute-if 'x #'cl-oddp '(1 2 3 4 5) :from-end t))) (should (equal result '(x 2 x 4 x)))) - (let ((result (cl-substitute-if 'x (lambda (n) (= n 3)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-substitute-if 'x (lambda (n) (= n 3)) '(1 2 3 4 5) + :key #'identity))) (should (equal result '(1 2 x 4 5))))) (ert-deftest cl-seq-substitute-if-not-test () @@ -260,21 +235,22 @@ cl-seq-substitute-if-not-test (should (equal result '(x 2 x 4 x)))) (let ((result (cl-substitute-if-not 'x #'cl-evenp '(2 4 6)))) (should (equal result '(2 4 6)))) - (let ((result (cl-substitute-if-not 'x #'(lambda (n) (> n 5)) '(1 2 3 4 5)))) + (let ((result (cl-substitute-if-not 'x (lambda (n) (> n 5)) '(1 2 3 4 5)))) (should (equal result '(x x x x x)))) (let ((result (cl-substitute-if-not 'x #'cl-evenp '(1 2 3 4 5) :start 0 :end 4))) (should (equal result '(x 2 x 4 5)))) (let ((result (cl-substitute-if-not 'x #'cl-oddp '(1 2 3 4 5) :from-end t))) (should (equal result '(1 x 3 x 5)))) - (let ((result (cl-substitute-if-not 'x (lambda (n) (= n 3)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-substitute-if-not 'x (lambda (n) (= n 3)) '(1 2 3 4 5) + :key #'identity))) (should (equal result '(x x 3 x x))))) (ert-deftest cl-find-if-test () (let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5)))) (should (equal result 2))) - (let ((result (cl-find-if #'(lambda (n) (> n 5)) '(1 2 3 4 5)))) + (let ((result (cl-find-if (lambda (n) (> n 5)) '(1 2 3 4 5)))) (should (equal result nil))) - (let ((result (cl-find-if #'(lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) + (let ((result (cl-find-if (lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) (should (equal result 4))) (let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5) :start 2))) (should (equal result 4))) @@ -282,7 +258,7 @@ cl-find-if-test (should (equal result nil))) (let ((result (cl-find-if #'cl-oddp '(2 4 5 6 7) :from-end t))) (should (equal result 7))) - (let ((result (cl-find-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-find-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity))) (should (equal result 4)))) (ert-deftest cl-find-if-not-test () @@ -290,7 +266,7 @@ cl-find-if-not-test (should (equal result 1))) (let ((result (cl-find-if-not #'cl-oddp '(1 3 5)))) (should (equal result nil))) - (let ((result (cl-find-if-not #'(lambda (n) (< n 4)) '(1 2 3 4 5 6 7)))) + (let ((result (cl-find-if-not (lambda (n) (< n 4)) '(1 2 3 4 5 6 7)))) (should (equal result 4))) (let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5) :start 2))) (should (equal result 3))) @@ -298,45 +274,40 @@ cl-find-if-not-test (should (equal result 1))) (let ((result (cl-find-if-not #'cl-oddp '(2 4 6 7 8) :from-end t))) (should (equal result 8))) - (let ((result (cl-find-if-not (lambda (n) (= n 4)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-find-if-not (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity))) (should (equal result 1)))) ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-nsubstitute-test () - (let ((cl-seq--test-list '(1 2 3 4 5 2 6)) - (orig (copy-sequence cl-seq--test-list)) - (tests '((should (equal '(1 b 3 4 5 b 6) (cl-nsubstitute 'b 2 _list))) - (should (equal _list (cl-substitute 'b 2 _list :start (length _list)))) - (should (equal _list (cl-substitute 'b 2 _list :end 0))) - (should (equal '(1 2 3 4 5 b 6) (cl-substitute 'b 2 _list :start 2))) - (should (equal '(1 b 3 4 5 2 6) (cl-substitute 'b 2 _list :end 2))) - (should (equal _list (cl-substitute 'b 2 _list :start 2 :end 4))) - (should (equal '(1 b 3 4 5 2 6) (cl-nsubstitute 'b 2 _list :count 1))) - (should (equal '(1 2 3 4 5 b 6) (cl-nsubstitute 'b 2 _list :count 1 :from-end t))) - (should (equal _list (cl-nsubstitute 'b 2 _list :count -1))) - (should (equal '(1 b 3 4 5 b 6) (cl-nsubstitute 'b "2" _list :key #'number-to-string - :test #'string=))) - (should (equal (cl-nsubstitute 'b 2 _list) - (cl-nsubstitute 'b 2 _list :test #'eq))) - (should (equal '(1 2 b b b 2 b) (cl-nsubstitute 'b 2 _list :test (lambda (a b) (< a b))))) - (should (equal '(b b 3 4 5 b 6) (cl-nsubstitute 'b 2 _list :test (lambda (a b) (>= a b))))) - (should (equal _list (cl-nsubstitute 'b 99 _list :test (lambda (a b) (< a b))))) - (should (equal (cl-nsubstitute 'b 2 _list :test (lambda (a b) (>= a b))) - (cl-nsubstitute 'b 2 _list :test-not (lambda (a b) (< a b))))) - (should (equal '(1 2 b b b 2 b) - (cl-nsubstitute 'b nil _list :if (lambda (x) (> (cl-position x _list) 1))))) - (should (equal '(1 b b b b b b) - (cl-nsubstitute 'b nil _list :if (lambda (x) (> (cl-position x _list :from-end t) 1))))) - (should (equal '(b b 3 4 5 b 6) - (cl-nsubstitute 'b nil _list - :if-not (lambda (x) (> (cl-position x _list) 1))))) - (should (equal '(b 2 3 4 5 2 6) - (cl-nsubstitute 'b nil _list - :if-not (lambda (x) (> (cl-position x _list :from-end t) 1)))))))) - (dolist (test tests) - (let ((_list cl-seq--test-list)) - (cl-seq--with-side-effects orig nil - test))))) + (cl-seq-tests--relet* ((l (list 1 2 3 4 5 2 6)) + (orig (copy-sequence l))) + (should (equal '(1 b 3 4 5 b 6) (cl-nsubstitute 'b 2 l))) + (should (equal orig (cl-nsubstitute 'b 2 l :start (length l)))) + (should (equal orig (cl-nsubstitute 'b 2 l :end 0))) + (should (equal '(1 2 3 4 5 b 6) (cl-nsubstitute 'b 2 l :start 2))) + (should (equal '(1 b 3 4 5 2 6) (cl-nsubstitute 'b 2 l :end 2))) + (should (equal orig (cl-nsubstitute 'b 2 l :start 2 :end 4))) + (should (equal '(1 b 3 4 5 2 6) (cl-nsubstitute 'b 2 l :count 1))) + (should (equal '(1 2 3 4 5 b 6) (cl-nsubstitute 'b 2 l :count 1 :from-end t))) + (should (equal orig (cl-nsubstitute 'b 2 l :count -1))) + (should (equal '(1 b 3 4 5 b 6) (cl-nsubstitute 'b "2" l + :key #'number-to-string + :test #'string=))) + (should (equal (cl-nsubstitute 'b 2 orig) + (cl-nsubstitute 'b 2 l :test #'eq))) + (should (equal '(1 2 b b b 2 b) (cl-nsubstitute 'b 2 l :test #'<))) + (should (equal '(b b 3 4 5 b 6) (cl-nsubstitute 'b 2 l :test #'>=))) + (should (equal orig (cl-nsubstitute 'b 99 l :test #'<))) + (should (equal (cl-nsubstitute 'b 2 orig :test #'>=) + (cl-nsubstitute 'b 2 l :test-not #'<))) + (let ((pred (lambda (x) (> (cl-position x orig) 1)))) + (should (equal '(1 2 b b b 2 b) (cl-nsubstitute 'b nil l :if pred)))) + (let ((pred (lambda (x) (> (cl-position x orig :from-end t) 1)))) + (should (equal '(1 b b b b b b) (cl-nsubstitute 'b nil l :if pred)))) + (let ((pred (lambda (x) (> (cl-position x orig) 1)))) + (should (equal '(b b 3 4 5 b 6) (cl-nsubstitute 'b nil l :if-not pred)))) + (let ((pred (lambda (x) (> (cl-position x orig :from-end t) 1)))) + (should (equal '(b 2 3 4 5 2 6) (cl-nsubstitute 'b nil l :if-not pred)))))) ;; keywords supported: :test :test-not :key :start :end :from-end (ert-deftest cl-seq-position-test () @@ -346,10 +317,10 @@ cl-seq-position-test (should (= 5 (cl-position 2 list :start 5 :end 6))) (should (= 1 (cl-position 2 list :from-end nil))) (should (= 5 (cl-position 2 list :from-end t))) - (should (cl-position 2 list :key #'identity - :test (lambda (a b) (eql a b)))) + (should (cl-position 2 list :key #'identity :test #'eql)) (should (= 1 (cl-position "2" list :key #'number-to-string :test #'string=))) - (should (= 5 (cl-position "2" list :key #'number-to-string :test #'string= :from-end t))) + (should (= 5 (cl-position "2" list :key #'number-to-string + :test #'string= :from-end t))) (should-not (cl-position "2" list :key #'number-to-string)) (should (cl-position 5 list :key (lambda (x) (1+ (* 1.0 x x))) :test #'=)) (should-not (cl-position 5 list :key (lambda (x) (1+ (* 1.0 x x))))) @@ -359,9 +330,9 @@ cl-seq-position-test (ert-deftest cl-position-if-test () (let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5)))) (should (equal result 1))) - (let ((result (cl-position-if #'(lambda (n) (> n 5)) '(1 2 3 4 5)))) + (let ((result (cl-position-if (lambda (n) (> n 5)) '(1 2 3 4 5)))) (should (equal result nil))) - (let ((result (cl-position-if #'(lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) + (let ((result (cl-position-if (lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) (should (equal result 3))) (let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5) :start 2))) (should (equal result 3))) @@ -369,7 +340,7 @@ cl-position-if-test (should (equal result nil))) (let ((result (cl-position-if #'cl-oddp '(2 4 5 6 7) :from-end t))) (should (equal result 4))) - (let ((result (cl-position-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-position-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity))) (should (equal result 3)))) ;; keywords supported: :test :test-not :key :start :end @@ -390,11 +361,11 @@ cl-count-if-test (should (equal result 2))) (let ((result (cl-count-if #'cl-oddp '(2 4 6 8)))) (should (equal result 0))) - (let ((result (cl-count-if (lambda (x) t) '(1 2 3 4)))) + (let ((result (cl-count-if #'always '(1 2 3 4)))) (should (equal result 4))) - (let ((result (cl-count-if (lambda (x) nil) '(1 2 3 4)))) + (let ((result (cl-count-if #'ignore '(1 2 3 4)))) (should (equal result 0))) - (let ((result (cl-count-if #'(lambda (x) (> x 2)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-count-if (lambda (x) (> x 2)) '(1 2 3 4 5) :key #'identity))) (should (equal result 3))) (let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5) :start 2))) (should (equal result 1))) @@ -402,7 +373,7 @@ cl-count-if-test (should (equal result 1))) (let ((result (cl-count-if #'cl-evenp '()))) (should (equal result 0))) - (let ((result (cl-count-if #'(lambda (x) (numberp x)) '(1 "two" 3 4 "five" 6)))) + (let ((result (cl-count-if #'numberp '(1 "two" 3 4 "five" 6)))) (should (equal result 4))) (let ((result (cl-count-if (lambda (x) (and (numberp x) (> x 2))) '(1 2 3 4 5 6)))) (should (equal result 4)))) @@ -412,11 +383,11 @@ cl-count-if-not-test (should (equal result 3))) (let ((result (cl-count-if-not #'cl-oddp '(1 3 5)))) (should (equal result 0))) - (let ((result (cl-count-if-not (lambda (x) t) '(1 2 3 4)))) + (let ((result (cl-count-if-not #'always '(1 2 3 4)))) (should (equal result 0))) - (let ((result (cl-count-if-not (lambda (x) nil) '(1 2 3 4)))) + (let ((result (cl-count-if-not #'ignore '(1 2 3 4)))) (should (equal result 4))) - (let ((result (cl-count-if-not #'(lambda (x) (> x 3)) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-count-if-not (lambda (x) (> x 3)) '(1 2 3 4 5) :key #'identity))) (should (equal result 3))) (let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5) :start 2))) (should (equal result 2))) @@ -424,9 +395,10 @@ cl-count-if-not-test (should (equal result 2))) (let ((result (cl-count-if-not #'cl-evenp '()))) (should (equal result 0))) - (let ((result (cl-count-if-not #'(lambda (x) (numberp x)) '(1 "two" 3 4 "five" 6)))) + (let ((result (cl-count-if-not #'numberp '(1 "two" 3 4 "five" 6)))) (should (equal result 2))) - (let ((result (cl-count-if-not (lambda (x) (and (numberp x) (> x 2))) '(1 2 3 4 5 6)))) + (let ((result (cl-count-if-not (lambda (x) (and (numberp x) (> x 2))) + '(1 2 3 4 5 6)))) (should (equal result 2)))) ;; keywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end @@ -443,9 +415,9 @@ cl-seq-mismatch-test (should-not (cl-mismatch list list2 :end1 1 :end2 1)) (should-not (cl-mismatch list list2 :start1 1 :start2 2)) (should (= 1 (cl-mismatch list list2 :start1 1 :end1 2 :start2 4 :end2 4))) - (should (= -1 (cl-mismatch list list2 :key #'number-to-string + (should (= -1 (cl-mismatch list list2 :from-end t :key #'number-to-string :test (lambda (a b) - (and (stringp a) (stringp b))) :from-end t))) + (and (stringp a) (stringp b)))))) (should (= 7 (cl-mismatch list list2 :key #'number-to-string :test (lambda (a b) (and (stringp a) (stringp b)))))))) @@ -461,16 +433,17 @@ cl-seq-search-test (should (= 0 (cl-search list list2 :end1 1))) (should (= 0 (cl-search nil list2))) (should (= 2 (cl-search list list2 :start1 1 :end1 2 :end2 3))) - (should (= 0 (cl-search list list2 :test (lambda (a b) (and (numberp a) (numberp b)))))) + (should (= 0 (cl-search list list2 :test (lambda (a b) + (and (numberp a) (numberp b)))))) (should (= 0 (cl-search list list2 :key (lambda (x) (and (numberp x) 'foo)) :test (lambda (a b) (and (eq a 'foo) (eq b 'foo)))))) (should (= 1 (cl-search (nthcdr 2 list) (nthcdr 2 list2)))) (should (= 3 (cl-search (nthcdr 2 list) list2))))) (ert-deftest cl-seq-test-bug24264 () - "Test for https://debbugs.gnu.org/24264 ." + "Test for bug#24264." :tags '(:expensive-test) - (let ((list (append (make-list 8000005 1) '(8))) + (let ((list (nconc (make-list 8000005 1) '(8))) (list2 (make-list 8000005 2))) (should (cl-position 8 list)) (should-not (equal '(8) (last (cl-remove 8 list)))) @@ -488,75 +461,82 @@ cl-seq-bignum-eql (should (eq (cl-rassoc x a) (cadr a)))))) (ert-deftest cl-sort-test () - (let ((result (cl-sort '(3 1 4 1 5 9 2 6 5 3 5) '<))) + (let ((result (cl-sort (list 3 1 4 1 5 9 2 6 5 3 5) #'<))) (should (equal result '(1 1 2 3 3 4 5 5 5 6 9)))) - (let ((result (cl-sort '(5 3 2 8 1 4) '>))) + (let ((result (cl-sort (list 5 3 2 8 1 4) #'>))) (should (equal result '(8 5 4 3 2 1)))) - (let ((result (cl-sort '("banana" "apple" "cherry") 'string<))) + (let ((result (cl-sort (list "banana" "apple" "cherry") #'string<))) (should (equal result '("apple" "banana" "cherry")))) - (let ((result (cl-sort '("banana" "fig" "apple" "kiwi") (lambda (x y) (< (length x) (length y))) :key 'identity))) + (let ((result (cl-sort (list "banana" "fig" "apple" "kiwi") + (lambda (x y) (length< x (length y))) + :key #'identity))) (should (equal result '("fig" "kiwi" "apple" "banana")))) - (let ((result (cl-sort (vector 3 1 4 1 5) '<))) - (should (equal result (vector 1 1 3 4 5)))) - (let ((result (cl-sort '(1 2 3 4 5) '<))) + (let ((result (cl-sort (vector 3 1 4 1 5) #'<))) + (should (equal result [1 1 3 4 5]))) + (let ((result (cl-sort (list 1 2 3 4 5) #'<))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-sort '(-3 1 4 -1 -5 9) '<))) + (let ((result (cl-sort (list -3 1 4 -1 -5 9) #'<))) (should (equal result '(-5 -3 -1 1 4 9)))) - (let ((result (cl-sort '(1 2 3 4 5) (lambda (x y) (> x y))))) + (let ((result (cl-sort (list 1 2 3 4 5) #'>))) (should (equal result '(5 4 3 2 1)))) - (let ((result (cl-sort '() '<))) + (let ((result (cl-sort '() #'<))) (should (equal result '()))) - (let ((result (cl-sort '("Banana" "apple" "cherry") 'string< :key 'downcase))) + (let ((result (cl-sort (list "Banana" "apple" "cherry") + #'string< :key #'downcase))) (should (equal result '("apple" "Banana" "cherry")))) ) (ert-deftest cl-stable-sort-test () - (let ((result (cl-stable-sort '(3 1 4 1 5 9 2 6 5 3 5) '<))) + (let ((result (cl-stable-sort (list 3 1 4 1 5 9 2 6 5 3 5) #'<))) (should (equal result '(1 1 2 3 3 4 5 5 5 6 9)))) - (let ((result (cl-stable-sort '(5 3 2 8 1 4) '>))) + (let ((result (cl-stable-sort (list 5 3 2 8 1 4) #'>))) (should (equal result '(8 5 4 3 2 1)))) - (let ((result (cl-stable-sort '("banana" "apple" "cherry") 'string<))) + (let ((result (cl-stable-sort (list "banana" "apple" "cherry") #'string<))) (should (equal result '("apple" "banana" "cherry")))) - (let ((result (cl-stable-sort '("banana" "fig" "apple" "kiwi") (lambda (x y) (< (length x) (length y))) :key 'identity))) + (let ((result (cl-stable-sort (list "banana" "fig" "apple" "kiwi") + (lambda (x y) (length< x (length y))) + :key #'identity))) (should (equal result '("fig" "kiwi" "apple" "banana")))) - (let ((result (cl-stable-sort (vector 3 1 4 1 5) '<))) - (should (equal result (vector 1 1 3 4 5)))) - (let ((result (cl-stable-sort '(1 2 3 4 5) '<))) + (let ((result (cl-stable-sort (vector 3 1 4 1 5) #'<))) + (should (equal result [1 1 3 4 5]))) + (let ((result (cl-stable-sort (list 1 2 3 4 5) #'<))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-stable-sort '(-3 1 4 -1 -5 9) '<))) + (let ((result (cl-stable-sort (list -3 1 4 -1 -5 9) #'<))) (should (equal result '(-5 -3 -1 1 4 9)))) - (let ((result (cl-stable-sort '(1 2 3 4 5) (lambda (x y) (> x y))))) + (let ((result (cl-stable-sort (list 1 2 3 4 5) #'>))) (should (equal result '(5 4 3 2 1)))) - (let ((result (cl-stable-sort '() '<))) + (let ((result (cl-stable-sort '() #'<))) (should (equal result '()))) - (let ((result (cl-stable-sort '("Banana" "apple" "cherry") 'string< :key 'downcase))) + (let ((result (cl-stable-sort (list "Banana" "apple" "cherry") + #'string< :key #'downcase))) (should (equal result '("apple" "Banana" "cherry")))) ) (ert-deftest cl-merge-test () - (let ((result (cl-merge 'list '(1 3 5) '(2 4 6) '<))) + (let ((result (cl-merge 'list (list 1 3 5) (list 2 4 6) #'<))) (should (equal result '(1 2 3 4 5 6)))) - (let ((result (cl-merge 'list '(1 3 3 5) '(2 3 4 6) '<))) + (let ((result (cl-merge 'list (list 1 3 3 5) (list 2 3 4 6) #'<))) (should (equal result '(1 2 3 3 3 4 5 6)))) - (let ((result (cl-merge 'list '() '(2 4 6) '<))) + (let ((result (cl-merge 'list '() (list 2 4 6) #'<))) (should (equal result '(2 4 6)))) - (let ((result (cl-merge 'list '(1 3 5) '() '<))) + (let ((result (cl-merge 'list (list 1 3 5) '() #'<))) (should (equal result '(1 3 5)))) - (let ((result (cl-merge 'list '() '() '<))) + (let ((result (cl-merge 'list '() '() #'<))) (should (equal result '()))) - (let ((result (cl-merge 'list '(1 4 6) '(2 3 5) '< :key (lambda (x) x)))) + (let ((result (cl-merge 'list (list 1 4 6) (list 2 3 5) #'< :key #'identity))) (should (equal result '(1 2 3 4 5 6)))) - (let ((result (cl-merge 'vector (vector 1 3 5) (vector 2 4 6) '<))) - (should (equal result (vector 1 2 3 4 5 6)))) - (let ((result (cl-merge 'list '(5 3 1) '(6 4 2) '>))) + (let ((result (cl-merge 'vector (vector 1 3 5) (vector 2 4 6) #'<))) + (should (equal result [1 2 3 4 5 6]))) + (let ((result (cl-merge 'list (list 5 3 1) (list 6 4 2) #'>))) (should (equal result '(6 5 4 3 2 1)))) - (let ((result (cl-merge 'list '(1 2 3) '(1 2 3) '>))) + (let ((result (cl-merge 'list (list 1 2 3) (list 1 2 3) #'>))) (should (equal result '(1 2 3 1 2 3)))) - (let ((result (cl-merge 'list '(1 2) '(3 4 5) '<))) + (let ((result (cl-merge 'list (list 1 2) (list 3 4 5) #'<))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-merge 'list '(4 5 6) '(1 2 3) '<))) + (let ((result (cl-merge 'list (list 4 5 6) (list 1 2 3) #'<))) (should (equal result '(1 2 3 4 5 6)))) - (let ((result (cl-merge 'list '(1 2 3) '(1.5 2.5 3.5) '<))) + (let ((result (cl-merge 'list (list 1 2 3) (list 1.5 2.5 3.5) #'<))) (should (equal result '(1 1.5 2 2.5 3 3.5)))) - (let ((result (cl-merge 'list '(1 2 3) '(10 20 30) '< :key (lambda (x) (* x 10))))) + (let ((result (cl-merge 'list (list 1 2 3) (list 10 20 30) + #'< :key (lambda (x) (* x 10))))) (should (equal result '(1 2 3 10 20 30))))) (ert-deftest cl-member-test () @@ -566,45 +546,49 @@ cl-member-test (should (equal result nil))) (let ((result (cl-member 'a '(a b a c d)))) (should (equal result '(a b a c d)))) - (let ((result (cl-member "test" '("test" "not-test" "test2") :test 'string=))) + (let ((result (cl-member "test" '("test" "not-test" "test2") :test #'string=))) (should (equal result '("test" "not-test" "test2")))) - (let ((result (cl-member 'x '(a b c d) :test-not 'eq))) + (let ((result (cl-member 'x '(a b c d) :test-not #'eq))) (should (equal result '(a b c d)))) - (let ((result (cl-member 3 '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-member 3 '(1 2 3 4 5) :key #'identity))) (should (equal result '(3 4 5)))) - (let ((result (cl-member 2.5 '(1 2 2.5 3) :test 'equal))) + (let ((result (cl-member 2.5 '(1 2 2.5 3) :test #'equal))) (should (equal result '(2.5 3)))) - (let ((result (cl-member 'a '(a a a a) :test 'eq))) + (let ((result (cl-member 'a '(a a a a) :test #'eq))) (should (equal result '(a a a a)))) (let ((result (cl-member 'a '()))) (should (equal result nil))) - (let ((result (cl-member 'b '(a c d) :test-not 'eq))) + (let ((result (cl-member 'b '(a c d) :test-not #'eq))) (should (equal result '(a c d)))) - (let ((result (cl-member 3 '(1 2 3 4 5) :key '1+))) + (let ((result (cl-member 3 '(1 2 3 4 5) :key #'1+))) (should (equal result '(2 3 4 5))))) (ert-deftest cl-member-if-test () (let ((result (cl-member-if #'cl-evenp '(1 2 3 4 5)))) (should (equal result '(2 3 4 5)))) - (let ((result (cl-member-if #'(lambda (x) nil) '(1 2 3 4 5)))) + (let ((result (cl-member-if #'ignore '(1 2 3 4 5)))) (should (equal result nil))) - (let ((result (cl-member-if #'(lambda (x) t) '(1 2 3 4 5)))) + (let ((result (cl-member-if #'always '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if #'(lambda (x) (= x 1)) '(1 2 3 4 5)))) + (let ((result (cl-member-if (lambda (x) (= x 1)) '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if #'(lambda (x) (and (numberp x) (cl-evenp x))) '(1 3 5 4 2)))) + (let ((result (cl-member-if (lambda (x) (and (numberp x) (cl-evenp x))) + '(1 3 5 4 2)))) (should (equal result '(4 2)))) - (let ((result (cl-member-if (lambda (x) (string= (number-to-string x) "3")) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-member-if (lambda (x) (string= (number-to-string x) "3")) + '(1 2 3 4 5) :key #'identity))) (should (equal result '(3 4 5)))) - (let ((result (cl-member-if #'(lambda (x) (eq x 'a)) '(a a a a)))) + (let ((result (cl-member-if (lambda (x) (eq x 'a)) '(a a a a)))) (should (equal result '(a a a a)))) (let ((result (cl-member-if #'cl-evenp '()))) (should (equal result nil))) - (let ((result (cl-member-if #'(lambda (x) (< x 0)) '(1 2 3 4 5)))) + (let ((result (cl-member-if #'cl-minusp '(1 2 3 4 5)))) (should (equal result nil))) - (let ((result (cl-member-if (lambda (x) (and (numberp x) (<= x 2))) '(1 "two" 3 0)))) + (let ((result (cl-member-if (lambda (x) (and (numberp x) (<= x 2))) + '(1 "two" 3 0)))) (should (equal result '(1 "two" 3 0)))) - (let ((result (cl-member-if (lambda (x) (> x 5)) '(1 2 3 6 7 8) :key 'identity))) + (let ((result (cl-member-if (lambda (x) (> x 5)) '(1 2 3 6 7 8) + :key #'identity))) (should (equal result '(6 7 8))))) (ert-deftest cl-member-if-not-test () @@ -612,23 +596,27 @@ cl-member-if-not-test (should (equal result '(1 2 3 4 5)))) (let ((result (cl-member-if-not #'cl-evenp '(2 4 6 8 10 11)))) (should (equal result '(11)))) - (let ((result (cl-member-if-not #'(lambda (x) (> x 5)) '(1 2 3 4 5)))) + (let ((result (cl-member-if-not (lambda (x) (> x 5)) '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if-not #'(lambda (x) t) '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'always '(1 2 3 4 5)))) (should (equal result nil))) - (let ((result (cl-member-if-not #'(lambda (x) (= x 1)) '(1 2 3 4 5)))) + (let ((result (cl-member-if-not (lambda (x) (= x 1)) '(1 2 3 4 5)))) (should (equal result '(2 3 4 5)))) - (let ((result (cl-member-if-not (lambda (x) (string= (number-to-string x) "2")) '(1 2 3 4 5) :key 'identity))) + (let ((result (cl-member-if-not (lambda (x) (string= (number-to-string x) "2")) + '(1 2 3 4 5) :key #'identity))) (should (equal result '(1 2 3 4 5)))) (let ((result (cl-member-if-not #'cl-evenp '()))) (should (equal result nil))) - (let ((result (cl-member-if-not #'(lambda (x) (eq x 'a)) '(a a a a)))) + (let ((result (cl-member-if-not (lambda (x) (eq x 'a)) '(a a a a)))) (should (equal result nil))) - (let ((result (cl-member-if-not #'(lambda (x) (< x 0)) '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'cl-minusp '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if-not #'(lambda (x) (or (numberp x) (stringp x) (eq x 'b))) '(a "b" 3 nil)))) + (let ((result (cl-member-if-not + (lambda (x) (or (numberp x) (stringp x) (eq x 'b))) + '(a "b" 3 nil)))) (should (equal result '(a "b" 3 nil)))) - (let ((result (cl-member-if-not (lambda (x) (numberp x)) '(1 "two" 3 "four" 5) :key 'identity))) + (let ((result (cl-member-if-not #'numberp '(1 "two" 3 "four" 5) + :key #'identity))) (should (equal result '("two" 3 "four" 5))))) (ert-deftest cl-assoc-test () @@ -636,13 +624,13 @@ cl-assoc-test (should (equal result '(b . 2)))) (let ((result (cl-assoc 'x '((a . 1) (b . 2) (c . 3))))) (should (equal result nil))) - (let ((result (cl-assoc "key" '(("key" . 1) ("not-key" . 2)) :test 'string=))) + (let ((result (cl-assoc "key" '(("key" . 1) ("not-key" . 2)) :test #'string=))) (should (equal result '("key" . 1)))) - (let ((result (cl-assoc 'a '((a . 1) (b . 2) (c . 3)) :test-not 'eq))) + (let ((result (cl-assoc 'a '((a . 1) (b . 2) (c . 3)) :test-not #'eq))) (should (equal result '(b . 2)))) - (let ((result (cl-assoc '2 '((1 . 'a) (2 . 'b) (3 . 'c)) :key 'identity))) + (let ((result (cl-assoc '2 '((1 . 'a) (2 . 'b) (3 . 'c)) :key #'identity))) (should (equal result '(2 . 'b)))) - (let ((result (cl-assoc 'a '((a . 1) (a . 2) (a . 3)) :test 'eq))) + (let ((result (cl-assoc 'a '((a . 1) (a . 2) (a . 3)) :test #'eq))) (should (equal result '(a . 1)))) (let ((result (cl-assoc 'a '()))) (should (equal result nil))) @@ -650,105 +638,142 @@ cl-assoc-test (should (equal result '(b . 2))))) (ert-deftest cl-assoc-if-test () - (let ((result (cl-assoc-if #'cl-evenp '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))))) + (let ((result (cl-assoc-if #'cl-evenp + '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))))) (should (equal result '(2 . "even")))) - (let ((result (cl-assoc-if #'(lambda (x) (= x 5)) '((1 . "one") (2 . "two") (3 . "three"))))) + (let ((result (cl-assoc-if (lambda (x) (= x 5)) + '((1 . "one") (2 . "two") (3 . "three"))))) (should (equal result nil))) - (let ((result (cl-assoc-if #'(lambda (x) (= x 1)) '((1 . "one") (2 . "two") (3 . "three"))))) + (let ((result (cl-assoc-if (lambda (x) (= x 1)) + '((1 . "one") (2 . "two") (3 . "three"))))) (should (equal result '(1 . "one")))) - (let ((result (cl-assoc-if #'(lambda (x) (string= x "baz")) '((foo . 1) (bar . 2) (baz . 3))))) + (let ((result (cl-assoc-if (lambda (x) (string= x "baz")) + '((foo . 1) (bar . 2) (baz . 3))))) (should (equal result '(baz . 3)))) - (let ((result (cl-assoc-if (lambda (x) (and (numberp x) (> x 2))) '((1 . "one") (3 . "three") (4 . "four"))))) + (let ((result (cl-assoc-if (lambda (x) (and (numberp x) (> x 2))) + '((1 . "one") (3 . "three") (4 . "four"))))) (should (equal result '(3 . "three")))) - (let ((result (cl-assoc-if #'(lambda (x) (> x 1)) '((0 . "zero") (1 . "one") (2 . "two"))))) + (let ((result (cl-assoc-if (lambda (x) (> x 1)) + '((0 . "zero") (1 . "one") (2 . "two"))))) (should (equal result '(2 . "two")))) (let ((result (cl-assoc-if #'cl-evenp '()))) (should (equal result nil))) - (let ((result (cl-assoc-if #'(lambda (x) (eq x 'a)) '((a . "first") (a . "second") (b . "third"))))) + (let ((result (cl-assoc-if (lambda (x) (eq x 'a)) + '((a . "first") (a . "second") (b . "third"))))) (should (equal result '(a . "first")))) - (let ((result (cl-assoc-if #'(lambda (x) (and (symbolp x) (not (eq x 'b)))) '((b . "b") (c . "c") (d . "d"))))) + (let ((result (cl-assoc-if (lambda (x) (and (symbolp x) (not (eq x 'b)))) + '((b . "b") (c . "c") (d . "d"))))) (should (equal result '(c . "c")))) - (let ((result (cl-assoc-if (lambda (x) (and (listp x) (> (length x) 1))) '(((1 2) . "pair 1") ((1) . "pair 2"))))) + (let ((result (cl-assoc-if #'cdr '(((1 2) . "pair 1") ((1) . "pair 2"))))) (should (equal result '((1 2) . "pair 1"))))) (ert-deftest cl-assoc-if-not-test () - (let ((result (cl-assoc-if-not #'cl-evenp '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))))) + (let* ((alist '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))) + (result (cl-assoc-if-not #'cl-evenp alist))) (should (equal result '(1 . "odd")))) - (let ((result (cl-assoc-if-not #'(lambda (x) (> x 0)) '((1 . "one") (2 . "two") (3 . "three"))))) + (let ((result (cl-assoc-if-not #'cl-plusp + '((1 . "one") (2 . "two") (3 . "three"))))) (should (equal result nil))) - (let ((result (cl-assoc-if-not #'(lambda (x) (< x 5)) '((1 . "one") (2 . "two") (3 . "three"))))) + (let ((result (cl-assoc-if-not (lambda (x) (< x 5)) + '((1 . "one") (2 . "two") (3 . "three"))))) (should (equal result nil))) - (let ((result (cl-assoc-if-not #'(lambda (x) (= x 1)) '((1 . "one") (2 . "two") (3 . "three"))))) + (let ((result (cl-assoc-if-not (lambda (x) (= x 1)) + '((1 . "one") (2 . "two") (3 . "three"))))) (should (equal result '(2 . "two")))) - (let ((result (cl-assoc-if-not #'(lambda (x) (string= x "baz")) '((foo . "first") (bar . "second") (baz . "third"))))) + (let ((result (cl-assoc-if-not + (lambda (x) (string= x "baz")) + '((foo . "first") (bar . "second") (baz . "third"))))) (should (equal result '(foo . "first")))) - (let ((result (cl-assoc-if-not (lambda (x) (and (numberp x) (> x 2))) '((1 . "one") (3 . "three") (4 . "four"))))) + (let ((result (cl-assoc-if-not (lambda (x) (and (numberp x) (> x 2))) + '((1 . "one") (3 . "three") (4 . "four"))))) (should (equal result '(1 . "one")))) - (let ((result (cl-assoc-if-not #'(lambda (x) (symbolp x)) '((1 . "one") (b . "bee") (2 . "two"))))) + (let ((result (cl-assoc-if-not #'symbolp + '((1 . "one") (b . "bee") (2 . "two"))))) (should (equal result '(1 . "one")))) (let ((result (cl-assoc-if-not #'cl-evenp '()))) (should (equal result nil))) - (let ((result (cl-assoc-if-not #'(lambda (x) (eq x 'a)) '((a . "first") (a . "second") (b . "third"))))) + (let ((result (cl-assoc-if-not (lambda (x) (eq x 'a)) + '((a . "first") (a . "second") (b . "third"))))) (should (equal result '(b . "third"))))) (ert-deftest cl-rassoc-test () - (let ((result (cl-rassoc 2 '(( "one" . 1) ("two" . 2) ("three" . 3))))) - (should (equal result (cons "two" 2)))) - (let ((result (cl-rassoc 4 '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc 2 '(("one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("two" . 2)))) + (let ((result (cl-rassoc 4 '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result nil))) - (let ((result (cl-rassoc 2 '(( "one" . 1) ("two" . 2) ("baz" . 2)) :test 'equal))) - (should (equal result (cons "two" 2)))) - (let ((result (cl-rassoc 2 '(( "one" . 1) ("two" . 2) ("three" . 3)) :test-not 'equal))) - (should (equal result (cons "one" 1)))) + (let ((result (cl-rassoc 2 '(("one" . 1) ("two" . 2) ("baz" . 2)) + :test #'equal))) + (should (equal result '("two" . 2)))) + (let ((result (cl-rassoc 2 '(("one" . 1) ("two" . 2) ("three" . 3)) + :test-not #'equal))) + (should (equal result '("one" . 1)))) (let ((result (cl-rassoc 1 '()))) (should (equal result nil))) - (let ((result (cl-rassoc 1 '(( "first" . 1) ("second" . 1) ("third" . 1))))) - (should (equal result (cons "first" 1)))) - (let ((result (cl-rassoc 3 '(( "one" . 1) ("two" . 2) ("three" . 3))))) - (should (equal result (cons "three" 3)))) - (let ((result (cl-rassoc 'found '((( "pair 1") . 1) ( "pair 2" . 2) ( "pair 3" . 3))))) + (let ((result (cl-rassoc 1 '(("first" . 1) ("second" . 1) ("third" . 1))))) + (should (equal result '("first" . 1)))) + (let ((result (cl-rassoc 3 '(("one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("three" . 3)))) + (let ((result (cl-rassoc 'found + '((("pair 1") . 1) ("pair 2" . 2) ("pair 3" . 3))))) (should (equal result nil)))) (ert-deftest cl-rassoc-if-test () - (let ((result (cl-rassoc-if #'cl-evenp '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if #'cl-evenp + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("two" . 2)))) - (let ((result (cl-rassoc-if #'cl-evenp '(( "one" . 1) ("three" . 3) ("five" . 5))))) + (let ((result (cl-rassoc-if #'cl-evenp + '(("one" . 1) ("three" . 3) ("five" . 5))))) (should (equal result nil))) - (let ((result (cl-rassoc-if #'(lambda (x) (= x 1)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if (lambda (x) (= x 1)) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) - (let ((result (cl-rassoc-if (lambda (x) (> x 1)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if (lambda (x) (> x 1)) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("two" . 2)))) - (let ((result (cl-rassoc-if #'(lambda (x) (and (numberp x) (< x 3))) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if (lambda (x) (and (numberp x) (< x 3))) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) (let ((result (cl-rassoc-if #'cl-evenp '()))) (should (equal result nil))) - (let ((result (cl-rassoc-if #'(lambda (x) (> x 0)) '(( "first" . 1) ("second" . 2) ("third" . 3))))) + (let ((result (cl-rassoc-if #'cl-plusp + '(("first" . 1) ("second" . 2) ("third" . 3))))) (should (equal result '("first" . 1)))) - (let ((result (cl-rassoc-if #'(lambda (x) (string= (number-to-string x) "two")) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if (lambda (x) (string= (number-to-string x) "two")) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result nil))) - (let ((result (cl-rassoc-if #'(lambda (x) (stringp x)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if #'stringp + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result nil)))) (ert-deftest cl-rassoc-if-not-test () - (let ((result (cl-rassoc-if-not #'cl-evenp '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if-not #'cl-evenp + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (> x 0)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if-not #'cl-plusp + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result nil))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (< x 5)) '(( "one" . 1) ("two" . 2) ("six" . 6))))) - (should (equal result '( "six" . 6)))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (= x 1)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if-not (lambda (x) (< x 5)) + '(("one" . 1) ("two" . 2) ("six" . 6))))) + (should (equal result '("six" . 6)))) + (let ((result (cl-rassoc-if-not (lambda (x) (= x 1)) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("two" . 2)))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (> x 2)) '(( "one" . 1) ("two" . 1) ("three" . 3))))) + (let ((result (cl-rassoc-if-not (lambda (x) (> x 2)) + '(("one" . 1) ("two" . 1) ("three" . 3))))) (should (equal result '("one" . 1)))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (and (numberp x) (< x 3))) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if-not (lambda (x) (and (numberp x) (< x 3))) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("three" . 3)))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (equal x 2)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if-not (lambda (x) (equal x 2)) + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) (let ((result (cl-rassoc-if-not #'cl-evenp '()))) (should (equal result nil))) - (let ((result (cl-rassoc-if-not #'(lambda (x) (numberp x)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (let ((result (cl-rassoc-if-not #'numberp + '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result nil))) - (let ((result (cl-rassoc-if-not (lambda (x) (and (listp x) (= (length x) 1))) '(((1 2) . 1) ((3 4) . 2) ((5) . 2))))) + (let ((result (cl-rassoc-if-not (lambda (x) (eql (proper-list-p x) 1)) + '(((1 2) . 1) ((3 4) . 2) ((5) . 2))))) (should (equal result '((1 2) . 1))))) (ert-deftest cl-intersection-test () @@ -760,9 +785,9 @@ cl-intersection-test (should (equal result '(1 2 3)))) (let ((result (cl-intersection '(1 1 2 3) '(1 2 2 3 4)))) (should (equal result '(3 2 1 1)))) - (let ((result (cl-intersection '(1 "two" 3) '(3 "two" 4)))) + (let ((result (cl-intersection `(1 ,(copy-sequence "two") 3) '(3 "two" 4)))) (should (equal result '(3)))) - (let ((result (cl-intersection '(1 2 3) '(3 2 1) :test 'equal))) + (let ((result (cl-intersection '(1 2 3) '(3 2 1) :test #'equal))) (should (equal result '(1 2 3)))) (let ((result (cl-intersection '(1 2 3) '(3 4 5) :key #'identity))) (should (equal result '(3)))) @@ -774,52 +799,20 @@ cl-intersection-test (should (equal result '(5 4 3))))) (ert-deftest cl-nintersection-test () - (let ((list1 '(1 2 3 4)) - (list2 '(3 4 5 6))) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '(4 3))) - (should (equal list1 '(1 2 3 4))) - (should (equal list2 '(3 4 5 6))))) - (let ((list1 '(1 2)) - (list2 '(3 4))) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '())) - (should (equal list1 '(1 2))) - (should (equal list2 '(3 4))))) - (let ((list1 '(1 2 3)) - (list2 '(1 2 3))) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '(1 2 3))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(1 2 3))))) - (let ((list1 '(1 1 2 2 3)) - (list2 '(2 2 3 4))) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '(3 2 2))) - (should (equal list1 '(1 1 2 2 3))) - (should (equal list2 '(2 2 3 4))))) - (let ((list1 '(1 "two" 3)) - (list2 '(3 "two" 4))) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '(3))) - (should (equal list1 '(1 "two" 3))) - (should (equal list2 '(3 "two" 4))))) - (let ((list1 '(1 2 3)) - (list2 '(3 2 1))) - (let ((result (cl-nintersection list1 list2 :test 'equal))) - (should (equal result '(1 2 3))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 2 1))))) - (let ((list1 '()) - (list2 '(1 2 3))) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '())) - (should (equal list1 '())) - (should (equal list2 '(1 2 3))))) - (let ((list1 '()) - (list2 '())) - (let ((result (cl-nintersection list1 list2))) - (should (equal result '()))))) + (should-not (cl-nintersection () ())) + (should-not (cl-nintersection () (list 1 2 3))) + (should-not (cl-nintersection (list 1 2) (list 3 4))) + (should (equal (cl-nintersection (list 1 2 3 4) (list 3 4 5 6)) + '(4 3))) + (should (equal (cl-nintersection (list 1 2 3) (list 1 2 3)) + '(1 2 3))) + (should (equal (cl-nintersection (list 1 1 2 2 3) (list 2 2 3 4)) + '(3 2 2))) + (should (equal (cl-nintersection (list 1 (copy-sequence "two") 3) + (list 3 "two" 4)) + '(3))) + (should (equal (cl-nintersection (list 1 2 3) (list 3 2 1) :test #'equal) + '(1 2 3)))) (ert-deftest cl-set-difference-test () (let ((result (cl-set-difference '(1 2 3 4) '(3 4 5 6)))) @@ -832,11 +825,11 @@ cl-set-difference-test (should (equal result '(1 1 2)))) (let ((result (cl-set-difference '(1 2 3) '(3 2 4)))) (should (equal result '(1)))) - (let ((result (cl-set-difference '(1 2 3) '(3 2 1) :test 'equal))) + (let ((result (cl-set-difference '(1 2 3) '(3 2 1) :test #'equal))) (should (equal result '()))) (let ((result (cl-set-difference '((1 . "one") (2 . "two") (3 . "three")) - '((1 . "uno") (2 . "dos")) - :key 'car))) + '((1 . "uno") (2 . "dos")) + :key #'car))) (should (equal result '((3 . "three"))))) (let ((result (cl-set-difference '() '(1 2 3)))) (should (equal result '()))) @@ -844,65 +837,29 @@ cl-set-difference-test (should (equal result '(1 2 3)))) (let ((result (cl-set-difference '(1 2 3 4 5) '(3 4 5 6 7)))) (should (equal result '(1 2)))) - (let ((list1 '(1 2 3)) - (list2 '(2 3 4))) - (cl-set-difference list1 list2) + (let ((list1 (list 1 2 3)) + (list2 (list 2 3 4))) + (should (equal (cl-set-difference list1 list2) '(1))) (should (equal list1 '(1 2 3))) (should (equal list2 '(2 3 4))))) (ert-deftest cl-nset-difference-test () - (let ((list1 '(1 2 3 4)) - (list2 '(3 4 5 6))) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '(1 2))) - (should (equal list1 '(1 2 3 4))) - (should (equal list2 '(3 4 5 6))))) - (let ((list1 '(1 2 3)) - (list2 '())) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '(1 2 3))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '())))) - (let ((list1 '(1 2 3)) - (list2 '(1 2 3))) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '())) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(1 2 3))))) - (let ((list1 '(1 1 2 2 3)) - (list2 '(3 4 5))) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '(1 1 2 2))) - (should (equal list1 '(1 1 2 2 3))) - (should (equal list2 '(3 4 5))))) - (let ((list1 '(1 2 3)) - (list2 '(3 2 4))) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '(1))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 2 4))))) - (let ((list1 '(1 2 3)) - (list2 '(3 2 1))) - (let ((result (cl-nset-difference list1 list2 :test 'equal))) - (should (equal result '())) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 2 1))))) - (let ((list1 '()) - (list2 '(1 2 3))) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '())) - (should (equal list1 '())) - (should (equal list2 '(1 2 3))))) - (let ((list1 '()) - (list2 '())) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '())))) - (let ((list1 '(1 2 3 4 5)) - (list2 '(3 4 5 6 7))) - (let ((result (cl-nset-difference list1 list2))) - (should (equal result '(1 2))) - (should (equal list1 '(1 2 3 4 5))) - (should (equal list2 '(3 4 5 6 7)))))) + (should-not (cl-nset-difference () ())) + (should-not (cl-nset-difference () (list 1 2 3))) + (should-not (cl-nset-difference (list 1 2 3) (list 1 2 3))) + (should-not (cl-nset-difference (list 1 2 3) (list 3 2 1) :test #'equal)) + (should (equal (cl-nset-difference (list 1 2 3) ()) + '(1 2 3))) + (should (equal (cl-nset-difference (list 1 2 3 4) (list 3 4 5 6)) + '(1 2))) + (should (equal (cl-nset-difference (list 1 1 2 2 3) (list 3 4 5)) + '(1 1 2 2))) + (should (equal (cl-nset-difference (list 1 2 3) (list 3 2 4)) + '(1))) + (should (equal (cl-nset-difference (list 1 2 3 4 5) (list 3 4 5 6 7)) + '(1 2))) + (should (equal (cl-nset-difference (list 1 (copy-sequence "a")) (list 1 "a")) + '("a")))) (ert-deftest cl-set-exclusive-or-test () (let ((result (cl-set-exclusive-or '(1 2 3) '(3 4 5)))) @@ -919,104 +876,51 @@ cl-set-exclusive-or-test (should (equal result '(1 2 4 5)))) (let ((result (cl-set-exclusive-or '(1 2 3) '(3 2 4)))) (should (equal result '(1 4)))) - (let ((result (cl-set-exclusive-or '(1 2 3) '(3 2 1) :test 'equal))) + (let ((result (cl-set-exclusive-or '(1 2 3) '(3 2 1) :test #'equal))) (should (equal result '()))) (let ((result (cl-set-exclusive-or '() '()))) (should (equal result '()))) - (let ((result (cl-set-exclusive-or '(1 2 3 4 5) '(3 4 5 6 7))) - (list1 '(1 2 3 4 5)) - (list2 '(3 4 5 6 7))) - (should (equal result '(1 2 6 7))) + (let ((list1 (list 1 2 3 4 5)) + (list2 (list 3 4 5 6 7))) + (should (equal (cl-set-exclusive-or list1 list2) '(1 2 6 7))) (should (equal list1 '(1 2 3 4 5))) (should (equal list2 '(3 4 5 6 7))))) (ert-deftest cl-nset-exclusive-or-test () - (let ((list1 '(1 2 3)) - (list2 '(3 4 5))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 2 4 5))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 4 5))))) - (let ((list1 '(1 2 3)) - (list2 '())) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 2 3))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '())))) - (let ((list1 '(1 2 3)) - (list2 '(1 2 3))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result nil))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(1 2 3)))) - (let ((list1 '(1 1 2 2 3)) - (list2 '(3 4 5))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 1 2 2 4 5))) - (should (equal list1 '(1 1 2 2 3))) - (should (equal list2 '(3 4 5))))) - (let ((list1 '(1 2 3)) - (list2 '(3 3 4 5))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 2 4 5))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 3 4 5))))) - (let ((list1 '(1 2 3)) - (list2 '(3 2 4))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 4))) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 2 4))))) - (let ((list1 '(1 2 3)) - (list2 '(3 2 1))) - (let ((result (cl-nset-exclusive-or list1 list2 :test 'equal))) - (should (equal result '())) - (should (equal list1 '(1 2 3))) - (should (equal list2 '(3 2 1))))) - (let ((list1 '()) - (list2 '(1 2 3))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 2 3))) - (should (equal list1 '())) - (should (equal list2 '(1 2 3))))) - (let ((list1 '()) - (list2 '())) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '())))) - (let ((list1 '(1 2 3 4 5)) - (list2 '(3 4 5 6 7))) - (let ((result (cl-nset-exclusive-or list1 list2))) - (should (equal result '(1 2 6 7))) - (should (equal list1 '(1 2 3 4 5))) - (should (equal list2 '(3 4 5 6 7)))))) + (should-not (cl-nset-exclusive-or () ())) + (should-not (cl-nset-exclusive-or (list 1 2 3) (list 1 2 3))) + (should-not (cl-nset-exclusive-or (list 1 2 3) (list 3 2 1) :test #'equal)) + (should (equal (cl-nset-exclusive-or (list 1 2 3) (list 3 4 5)) + '(1 2 4 5))) + (should (equal (cl-nset-exclusive-or (list 1 2 3) ()) + '(1 2 3))) + (should (equal (cl-nset-exclusive-or (list 1 1 2 2 3) (list 3 4 5)) + '(1 1 2 2 4 5))) + (should (equal (cl-nset-exclusive-or (list 1 2 3) (list 3 3 4 5)) + '(1 2 4 5))) + (should (equal (cl-nset-exclusive-or (list 1 2 3) (list 3 2 4)) + '(1 4))) + (should (equal (cl-nset-exclusive-or () (list 1 2 3)) + '(1 2 3))) + (should (equal (cl-nset-exclusive-or (list 1 2 3 4 5) (list 3 4 5 6 7)) + '(1 2 6 7)))) (ert-deftest cl-subsetp-test () - (let ((result (cl-subsetp '(1 2) '(1 2 3 4)))) - (should (equal result t))) - (let ((result (cl-subsetp '() '(1 2 3 4)))) - (should (equal result t))) - (let ((result (cl-subsetp '(1 2) '()))) - (should (equal result nil))) - (let ((result (cl-subsetp '(1 2 3) '(1 2 3)))) - (should (equal result t))) - (let ((result (cl-subsetp '(1 1 2) '(1 2 3)))) - (should (equal result t))) - (let ((result (cl-subsetp '(1 2) '(1 1 2 3 4)))) - (should (equal result t))) - (let ((result (cl-subsetp '(1 "two" 3) '(3 "two" 1)))) - (should (equal result nil))) - (let ((result (cl-subsetp '(1 2) '(2 1) :test 'equal))) - (should (equal result t))) - (let ((result (cl-subsetp '((1 . "one") (2 . "two")) '((1 . "uno") (2 . "dos")) :key 'car))) - (should (equal result t))) - (let ((result (cl-subsetp '(1 2) '(3 4 2 1) :test 'eq))) - (should (equal result t))) - (let ((result (cl-subsetp '((1 2) (3)) '((1 2 . "found") (3 . "found")) :key 'car))) - (should (equal result t))) - (let ((result (cl-subsetp '(1 2) '(1 2 3 2)))) - (should (equal result t))) - (let ((result (cl-subsetp '() '()))) - (should (equal result t)))) + (should (cl-subsetp '(1 2) '(1 2 3 4))) + (should (cl-subsetp () '(1 2 3 4))) + (should-not (cl-subsetp '(1 2) ())) + (should (cl-subsetp '(1 2 3) '(1 2 3))) + (should (cl-subsetp '(1 1 2) '(1 2 3))) + (should (cl-subsetp '(1 2) '(1 1 2 3 4))) + (should-not (cl-subsetp '(1 "two" 3) '(3 "two" 1))) + (should (cl-subsetp '(1 2) '(2 1) :test #'equal)) + (should (cl-subsetp '((1 . "one") (2 . "two")) + '((1 . "uno") (2 . "dos")) + :key #'car)) + (should (cl-subsetp '(1 2) '(3 4 2 1) :test #'eq)) + (should (cl-subsetp '((1 2) (3)) '((1 2 . "found") (3 . "found")) :key #'car)) + (should (cl-subsetp '(1 2) '(1 2 3 2))) + (should (cl-subsetp () ()))) (provide 'cl-seq-tests) ;;; cl-seq-tests.el ends here -- 2.45.2 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 18 Jan 2025 14:19:54 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 09:19:54 2025 Received: from localhost ([127.0.0.1]:40771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZ9g1-0001yl-Og for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 09:19:54 -0500 Received: from flow-b3-smtp.messagingengine.com ([202.12.124.138]:34037) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1tZ9fz-0001yX-1k for 75633 <at> debbugs.gnu.org; Sat, 18 Jan 2025 09:19:51 -0500 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailflow.stl.internal (Postfix) with ESMTP id 460C91D409C9; Sat, 18 Jan 2025 09:19:45 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sat, 18 Jan 2025 09:19:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enzu.ru; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1737209985; x=1737213585; bh=z4E6Z2cI37 c3mYZhRwSyrnVk+EGXTB5GOELueCYPOR8=; b=Xj/MAqWwvuVSO6NofTY6YhEtO8 kHY8aeEYJhUlqAFOI0YIAIg/dThiYfIZwKnx7C8H1gW5UmOtLGI1HlUEKOyg/Rsx biB8JT5GCpe620TxoTqBe80g0kbukhtSzdRYQKYNpJqtKR274vDK+GsJ8bGHt6Z8 zw7SpaTxdnEZhMUmMj3tpP/H2q3q+ZbofjKZ3CUAWggACtKKzwI4KfoVaAsXCIJX Lz5cdQ9eBTk0Phk8htyJgY5P50iaYdCNxMvGYDY+Er2HAXqrNGgpeSqIs/pyqc46 +EJjwGLTE7gI8bixI2OLqxjkm0BPk+cSuW5lS4sSVV8mLI8EMqygM2+tpdig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1737209985; x=1737213585; bh=z4E6Z2cI37c3mYZhRwSyrnVk+EGXTB5GOEL ueCYPOR8=; b=RfZLdSUyVo63tPCH4Xy0W25zbEfl0/VFs1RAOhBZcOnIoAmb9tt NyHpTdhQJlpWB7Um5HOxoCz5IGV/jEgk7YFGwb6kDqYYqg/WpB5lgcx194jHFxTQ Kn0ARci+SDTqv6jiQlrZeoHIEbwWnofo9IlidugBxCWCjy5utiyYMgs9FOJ+yTMl TpRIPvPKHDRFYAStFKqdmpI9pP32dsPefDldI8/AFjHzMqooOqHqEdhpTUv9pmvQ +iU40YE8f/2dtTyUZ/hED08C8S6dvO25nGLBpumfd06GcZ7uee3N6tDwjHLizeet I2cX+jaGtVT8DT+zFIvabjHcN5GvYCTDHkA== X-ME-Sender: <xms:gLiLZ1p--2-wx2T46wmIP2niWhLcqwFTeNwA3UzmtBnRZ-Eg2JliUw> <xme:gLiLZ3rEh3CKiIigNIYKEKkGZLQQM_ISO1eFa_UlEMR0Kwj2xpF2Tn9JnxToHTRtu s7H04TOXlNyCAE1Hs0> X-ME-Received: <xmr:gLiLZyOcLMgsQejbKaO-w8-9OX-N4Noxknpl2XhBbzR75KJ3UeQnSz0sTHdhM3UgjwcuaqBbhSC9cyI3HQ> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeihedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf gjfhgffffkgggtsehttdertddtredtnecuhfhrohhmpeethhhmvgguucfmhhgrnhiirggu rgcuoehmvgesvghniihurdhruheqnecuggftrfgrthhtvghrnhepteffkeehteejkeejgf fgffektefgkedutdejgfeuvdfgvefhuddvleevffekkeeknecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgvsegvnhiiuhdrrhhupdhnsggprh gtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeejheeifeefsegu vggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepvghlihiisehgnhhurdhorhhg X-ME-Proxy: <xmx:gLiLZw5Zbd4DtwuJnNSafWxpUc4qzGCTxY4yR3WHBbUHEOGmCgUCOQ> <xmx:gLiLZ05DvWvonP1mHBF6k_QfGJVN-MjbRma1O3-yXjhg1SOK8KrQPA> <xmx:gLiLZ4hY3Bp4xLjrIE2EyZrNdl18__-rjLgnrJqlARgg5sziNCcPXw> <xmx:gLiLZ25zWWcy3OHsTauXtIha7-i8qe6u735NHgpJGq7BhIgsdrTd9Q> <xmx:gLiLZ5VM7m-rtEMVxWK6NSR4cgF4L9RmwikqUqeJvCmIpILZ7H-j7KUW> Feedback-ID: i93f64880:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Jan 2025 09:19:44 -0500 (EST) From: Ahmed Khanzada <me@HIDDEN> To: eliz@HIDDEN Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib In-Reply-To: <861px0bchx.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 18 Jan 2025 13:14:02 +0200") References: <87wmetpk5r.fsf@HIDDEN> <861px0bchx.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Sat, 18 Jan 2025 09:19:43 -0500 Message-ID: <8734hgjjb4.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 75633 Cc: 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Thanks for catching oddp and evenp, I suppose I must still have an outdated cl library without the prefix floating in my Emacs instance. Some packages still use it unfortunately, even after I submit patches updating them to cl-lib. Yes, I will look into the cl-seq-tests byecompiling warnings and fix them. Thank you, Ahmed Eli Zaretskii <eliz@HIDDEN> writes: >> From: Ahmed Khanzada <me@HIDDEN> >> Date: Fri, 17 Jan 2025 09:52:32 -0500 >> >> In response to the concerns about cl-lib last year (or was it the year >> before that?), I have written new unit tests that cover almost all cl-lib >> functions without tests in the cl-lib.el, cl-extra.el, and cl-seq.el >> files, with the notable exception of the tree functions. (I'll probably >> do those later). > > Thanks, additions to the test suite are always welcome. > > I've installed this on the master branch, but I found a couple of > problems with the new tests: > > . they use 'oddp' and 'evenp', which don't exist; I replaced them > with 'cl-oddp' and 'cl-evenp' -- if that is incorrect, please > submit followup patches to fix my changes > . cl-seq-tests.el emits warnings when byte compiling it (shown > below); could you please fix those? > > ELC lisp/emacs-lisp/cl-seq-tests.elc > > In toplevel form: > lisp/emacs-lisp/cl-seq-tests.el:179:6: Warning: value from call to `cl-delete-if' is unused > lisp/emacs-lisp/cl-seq-tests.el:249:49: Warning: Unused lexical argument `n' > lisp/emacs-lisp/cl-seq-tests.el:393:39: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:395:39: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:415:43: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:417:43: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:491:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:493:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:495:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:497:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:501:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:503:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:505:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:509:18: Warning: `cl-sort' on constant list (arg 1) > > lisp/emacs-lisp/cl-seq-tests.el:513:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:515:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:517:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:519:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:523:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:525:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:527:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:531:18: Warning: `cl-stable-sort' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:535:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:535:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:537:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:537:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:539:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:541:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:545:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:545:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:549:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:549:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:551:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:551:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:553:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:553:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:555:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:555:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:557:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:557:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:559:18: Warning: `cl-merge' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:559:18: Warning: `cl-merge' on constant list (arg 3) > lisp/emacs-lisp/cl-seq-tests.el:589:42: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:591:42: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:617:46: Warning: Unused lexical argument `x' > lisp/emacs-lisp/cl-seq-tests.el:779:20: Warning: `cl-nintersection' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:779:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:785:20: Warning: `cl-nintersection' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:785:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:791:20: Warning: `cl-nintersection' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:791:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:797:20: Warning: `cl-nintersection' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:797:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:803:20: Warning: `cl-nintersection' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:803:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:809:20: Warning: `cl-nintersection' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:809:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:815:20: Warning: `cl-nintersection' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:849:6: Warning: value from call to `cl-set-difference' is unused > lisp/emacs-lisp/cl-seq-tests.el:856:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:856:20: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:862:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:868:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:868:20: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:874:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:874:20: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:880:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:880:20: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:886:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:886:20: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:892:22: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:902:20: Warning: `cl-nset-difference' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:902:20: Warning: `cl-nset-difference' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:936:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:936:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:942:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:948:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:948:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:954:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:954:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:960:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:960:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:966:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:966:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:972:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:972:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:978:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) > lisp/emacs-lisp/cl-seq-tests.el:988:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) > lisp/emacs-lisp/cl-seq-tests.el:988:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2)
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at 75633) by debbugs.gnu.org; 18 Jan 2025 11:14:16 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 06:14:16 2025 Received: from localhost ([127.0.0.1]:40454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZ6mN-0004K7-S6 for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 06:14:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58638) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tZ6mK-0004Jn-Jm for 75633 <at> debbugs.gnu.org; Sat, 18 Jan 2025 06:14:14 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1tZ6mF-0007js-4K; Sat, 18 Jan 2025 06:14:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9CrLA8OKu8WQsPuN0K2XLooz+PrR4oaafT7EwklAgmc=; b=F1eQQU4Nd1dJ QddbCcW+ULSJMHWZ05PYDvelRFA7W2iXCtljW4ei+2YiCqqvGDGwtgWp4VohHhspLrqFx/NuN2YzS M0Qc4JZjebMD187FzvFIjMcYNQj2Zd6Hik4UZGv5vm0QXwGhYjxoZChViIRFCAatXkBZLJl4XfMna 4BbNpR4RtcW3Hcwfqc9zyESZA8qzWk8uh2aD7/w42FKykUSwmpbSaiRmVwyhrqnxlRYuA/KzP437D CBg/OhhT2QoD8+kdaLwz1y6U//yl425ahwHMeTcaR5agl1BgiJzV//kaxaYPJzZdOq2XAOAHOEJGM Lu9/XsncK2IekZA/om8RGA==; Date: Sat, 18 Jan 2025 13:14:02 +0200 Message-Id: <861px0bchx.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Ahmed Khanzada <me@HIDDEN> In-Reply-To: <87wmetpk5r.fsf@HIDDEN> (message from Ahmed Khanzada on Fri, 17 Jan 2025 09:52:32 -0500) Subject: Re: bug#75633: [PATCH] New unit-tests for cl-lib References: <87wmetpk5r.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75633 Cc: 75633 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Ahmed Khanzada <me@HIDDEN> > Date: Fri, 17 Jan 2025 09:52:32 -0500 > > In response to the concerns about cl-lib last year (or was it the year > before that?), I have written new unit tests that cover almost all cl-lib > functions without tests in the cl-lib.el, cl-extra.el, and cl-seq.el > files, with the notable exception of the tree functions. (I'll probably > do those later). Thanks, additions to the test suite are always welcome. I've installed this on the master branch, but I found a couple of problems with the new tests: . they use 'oddp' and 'evenp', which don't exist; I replaced them with 'cl-oddp' and 'cl-evenp' -- if that is incorrect, please submit followup patches to fix my changes . cl-seq-tests.el emits warnings when byte compiling it (shown below); could you please fix those? ELC lisp/emacs-lisp/cl-seq-tests.elc In toplevel form: lisp/emacs-lisp/cl-seq-tests.el:179:6: Warning: value from call to `cl-delete-if' is unused lisp/emacs-lisp/cl-seq-tests.el:249:49: Warning: Unused lexical argument `n' lisp/emacs-lisp/cl-seq-tests.el:393:39: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:395:39: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:415:43: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:417:43: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:491:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:493:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:495:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:497:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:501:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:503:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:505:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:509:18: Warning: `cl-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:513:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:515:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:517:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:519:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:523:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:525:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:527:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:531:18: Warning: `cl-stable-sort' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:535:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:535:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:537:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:537:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:539:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:541:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:545:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:545:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:549:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:549:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:551:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:551:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:553:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:553:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:555:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:555:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:557:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:557:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:559:18: Warning: `cl-merge' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:559:18: Warning: `cl-merge' on constant list (arg 3) lisp/emacs-lisp/cl-seq-tests.el:589:42: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:591:42: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:617:46: Warning: Unused lexical argument `x' lisp/emacs-lisp/cl-seq-tests.el:779:20: Warning: `cl-nintersection' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:779:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:785:20: Warning: `cl-nintersection' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:785:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:791:20: Warning: `cl-nintersection' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:791:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:797:20: Warning: `cl-nintersection' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:797:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:803:20: Warning: `cl-nintersection' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:803:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:809:20: Warning: `cl-nintersection' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:809:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:815:20: Warning: `cl-nintersection' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:849:6: Warning: value from call to `cl-set-difference' is unused lisp/emacs-lisp/cl-seq-tests.el:856:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:856:20: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:862:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:868:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:868:20: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:874:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:874:20: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:880:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:880:20: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:886:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:886:20: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:892:22: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:902:20: Warning: `cl-nset-difference' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:902:20: Warning: `cl-nset-difference' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:936:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:936:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:942:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:948:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:948:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:954:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:954:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:960:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:960:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:966:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:966:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:972:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:972:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:978:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2) lisp/emacs-lisp/cl-seq-tests.el:988:20: Warning: `cl-nset-exclusive-or' on constant list (arg 1) lisp/emacs-lisp/cl-seq-tests.el:988:20: Warning: `cl-nset-exclusive-or' on constant list (arg 2)
bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 17 Jan 2025 14:52:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 17 09:52:59 2025 Received: from localhost ([127.0.0.1]:36557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tYniS-0000kP-3w for submit <at> debbugs.gnu.org; Fri, 17 Jan 2025 09:52:58 -0500 Received: from lists.gnu.org ([2001:470:142::17]:57886) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1tYniN-0000k4-63 for submit <at> debbugs.gnu.org; Fri, 17 Jan 2025 09:52:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <me@HIDDEN>) id 1tYniG-0002ry-85 for bug-gnu-emacs@HIDDEN; Fri, 17 Jan 2025 09:52:45 -0500 Received: from flow-a8-smtp.messagingengine.com ([103.168.172.143]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <me@HIDDEN>) id 1tYniA-0006F9-2B for bug-gnu-emacs@HIDDEN; Fri, 17 Jan 2025 09:52:43 -0500 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailflow.phl.internal (Postfix) with ESMTP id B8E14200F13 for <bug-gnu-emacs@HIDDEN>; Fri, 17 Jan 2025 09:52:34 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 17 Jan 2025 09:52:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enzu.ru; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm1; t=1737125554; x=1737129154; bh=n6YHa8yIKbakROqT18ZD1fmqWn0fvA6g EAIVc4jdN7A=; b=QhixIhjZZZChFSU3wjn5sv/ihLMbIlLQfCJR/A8SAw3Q7J6C 0LwIJfXSbHjhko1hhWc32SQULjAvwFTqXwOvQs07lZlDdLnzJLgNUuyxBtjb/S+b uLw2XdqDzpPg4S/4QFga9vaTDwlI8sMzGoR1L13bEUUzt4LN0Hf9cSa9oVqwiPOx nfwC58apdzgdZwvN1U1OyEELgu4RLRj1ZgPEGNZNFAeKcvsolaK8RxgbJ7NAFg6S HrpaiIqD1OxytC9S715Ck8TZ2/Ou7MxYT/i+P/UxtmjxOLNZLUd6WUb/wgPLI5by YdFlcBgHZElG0olnbTvkXjDlKkRqk/rYK8I22g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1737125554; x= 1737129154; bh=n6YHa8yIKbakROqT18ZD1fmqWn0fvA6gEAIVc4jdN7A=; b=u 1a9ecSGaK/pu7JVpKI3xgQgvvTs/+m1Zn5wEmszlpgqKJCNTRbGiMSL4qIe5B6bP 0RYUGKEw5tftrHvRL3mUcxgpHoEQHOOIbNgJYr2WpgdAUOnQfI5Ag+fFGJJXpZo+ XEJYVYXlcrhLrCd2PZDKQsZ0GPXl8Nfl4kf0GDAKqY40a/ZWvp/9MUhDqKfkCMjU Gpyeb75P63ME7xMqVIhsgPqrkznpbeO1t7LMT3vm7gWSSKbbguKKIRPDKOkSperY Zm/PVvWHyQPcgY8qZHPnCJkp9FS+ef9KvgCKIzwXNL0Ie+yIOt0qkB+SrQb/RIVj iyVyqNJPXgl+blE6Ow3FA== X-ME-Sender: <xms:sW6KZy9DOJ6HqZBDgoQZmpFyETVJJCYwlkpwc_drlVu4FR-yCGleNQ> <xme:sW6KZyvxmuO4cW6kvkfErUljZ7FHmRcDghNf9uhLfsd4DxMhw7-cSf41DxW8yf1i3 w9SRx9h1jq5-etqeGA> X-ME-Received: <xmr:sW6KZ4CpqbJ8LRpb-OowYTJ2xlUfXin2oL_1inIjUGeBgkKWuo2AkHbQYd1o-uIVKBZAFLdPhktoH0DriA> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeifedgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkfggtgesmhdtreertddttdenucfhrhhomheptehhmhgvugcumfhhrghniigruggruceo mhgvsegvnhiiuhdrrhhuqeenucggtffrrghtthgvrhhnpeeuvddvhedvtdeivefgtefhge ffjeefvddtgeejtddvffetheegfffhgfdvhfejkeenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehmvgesvghniihurdhruhdpnhgspghrtghpth htohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghughdqghhnuhdqvghm rggtshesghhnuhdrohhrgh X-ME-Proxy: <xmx:sW6KZ6eXaQfZ3RXCdQRz26upjSEdTgiCwGIKkLBUyOp1hesAJc-hjg> <xmx:sW6KZ3NgbeKUAn6BSDdU2bsgNJ3cQIsvYdoHzLztwykyD4ElOWHZIQ> <xmx:sW6KZ0n_I9LcsyGTKYicjHK3nmURZR70Bfbkl7eHsuU1plgirRoFxA> <xmx:sW6KZ5vZmOiRYs3oHmktIH22fmhYa1jSnmyl46tshoodyA8dWsJGCg> <xmx:sW6KZ9ZEFsovWJNvbMVqSTRwrkuhuwjpO8iawpOacW_ZW2xac81vrcWf> Feedback-ID: i93f64880:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <bug-gnu-emacs@HIDDEN>; Fri, 17 Jan 2025 09:52:33 -0500 (EST) From: Ahmed Khanzada <me@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: [PATCH] New unit-tests for cl-lib Date: Fri, 17 Jan 2025 09:52:32 -0500 Message-ID: <87wmetpk5r.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=103.168.172.143; envelope-from=me@HIDDEN; helo=flow-a8-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) --=-=-= Content-Type: text/plain Tags: patch In response to the concerns about cl-lib last year (or was it the year before that?), I have written new unit tests that cover almost all cl-lib functions without tests in the cl-lib.el, cl-extra.el, and cl-seq.el files, with the notable exception of the tree functions. (I'll probably do those later). In GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) Windowing system distributor 'The X.Org Foundation', version 11.0.12101012 System Description: Guix System Configured using: 'configure CONFIG_SHELL=/gnu/store/6nqyia3ra10sgd1ppzk2047ncbzjwhff-bash-minimal-5.1.16/bin/bash SHELL=/gnu/store/6nqyia3ra10sgd1ppzk2047ncbzjwhff-bash-minimal-5.1.16/bin/bash --prefix=/gnu/store/i4cnvwb1hm21yd27mwb03hqwd14hck99-emacs-29.4 --enable-fast-install --with-cairo --with-modules --with-native-compilation=aot --disable-build-details' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-New-unit-tests-for-cl-lib.patch Content-Transfer-Encoding: 8bit From 5073dfd1f9812ca591068e8e39b0f1e8c0c379de Mon Sep 17 00:00:00 2001 From: Ahmed Khanzada <me@HIDDEN> Date: Fri, 17 Jan 2025 09:48:57 -0500 Subject: [PATCH] New unit-tests for cl-lib --- test/lisp/emacs-lisp/cl-extra-tests.el | 177 +++++++ test/lisp/emacs-lisp/cl-lib-tests.el | 112 ++++ test/lisp/emacs-lisp/cl-seq-tests.el | 708 ++++++++++++++++++++++++- 3 files changed, 996 insertions(+), 1 deletion(-) diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el index b74e79aa9e0..dc1a52c9716 100644 --- a/test/lisp/emacs-lisp/cl-extra-tests.el +++ b/test/lisp/emacs-lisp/cl-extra-tests.el @@ -29,6 +29,33 @@ (should (eq (cl-get 'cl-get-test 'y :none) nil)) (should (eq (cl-get 'cl-get-test 'z :none) :none))) +(ert-deftest cl-extra-test-coerce () + (should (equal (cl-coerce "abc" 'list) '(?a ?b ?c))) + (should (equal (cl-coerce ["a" "b" "c"] 'list) '("a" "b" "c"))) + (should (equal (cl-coerce "abc" 'vector) [97 98 99])) + (should (equal (cl-coerce '("a" "b" "c") 'vector) ["a" "b" "c"])) + (should (equal (cl-coerce '(3 4) 'bool-vector) #&2"")) + (should (equal (cl-coerce "abc" 'bool-vector) #&3"")) + (should (equal (cl-coerce [1] 'string) (char-to-string 1))) + (should (equal (cl-coerce '(1) 'string) (char-to-string 1))) + (should (equal (cl-coerce '(1 2 3) 'array) [1 2 3])) + (should (equal (cl-coerce "abc" 'array) "abc")) + (should-error (cl-coerce (list 1 2 3) 'character)) + (should-error (cl-coerce [1 2 3] 'character)) + (should-error (cl-coerce "abc" 'character)) + (should (equal (cl-coerce "a" 'character) 97)) + (should (equal (cl-coerce 'a 'character) 97))) + +(ert-deftest cl-extra-test-equalp () + (should (cl-equalp "Test" "test")) + (should (cl-equalp 1 1.0)) + (should (cl-equalp '(1 2 3) '(1 2 3))) + (should (cl-equalp [1 2 3] [1 2 3])) + (should-not (cl-equalp "Test1" "Test2")) + (should-not (cl-equalp 1 2)) + (should-not (cl-equalp '(1 2 3) '(4 5 6))) + (should-not (cl-equalp [1 2 3] [4 5 6]))) + (ert-deftest cl-getf () (let ((plist '(x 1 y nil))) (should (eq (cl-getf plist 'x) 1)) @@ -127,4 +154,154 @@ (should (equal (cl-concatenate 'string "123" "456") "123456"))) +(ert-deftest cl-extra-test-mapcan () + (should (equal (cl-mapcan #'list '(1 2 3)) '(1 2 3))) + (should (equal (cl-mapcan #'list '(1 2 3) '(4 5 6)) '(1 4 2 5 3 6))) + (should (equal (cl-mapcan #'list '(1 2) '(3 4 5)) '(1 3 2 4))) + (should (equal (cl-mapcan #'list '(1 2 3) "#$%") '(1 ?# 2 ?$ 3 ?%))) + (should (equal (cl-mapcan #'list '()) '())) + (should (equal (cl-mapcan #'list '() '()) '()))) + +(ert-deftest cl-extra-test-mapcon () + (should (equal (cl-mapcon #'list '(1 2 3)) '((1 2 3) (2 3) (3)))) + (should (equal (cl-mapcon #'list '()) nil)) + (should (equal (cl-mapcon #'list '() '()) nil))) + +(ert-deftest cl-extra-test-some () + (should (equal (cl-some #'identity (list nil nil "foo")) "foo")) + (should (equal (cl-some #'identity [nil nil nil]) nil)) + (should (equal (cl-some (lambda (a b) (> (+ a b) 198)) (list ?a ?b ?c) "abcz") nil)) + (should (equal (cl-some (lambda (a b) (> (+ a b) 198)) (list ?a ?b ?c) "abz") t))) + +(ert-deftest cl-extra-test-every () + (should (equal (cl-every #'identity (list t 42 "foo")) t)) + (should (equal (cl-every #'identity [t nil "foo"]) nil)) + (should (equal (cl-every (lambda (a b) (<= (+ a b) 198)) + (list ?a ?b ?c) "abcz") + t)) + (should (equal (cl-every (lambda (a b) (<= (+ a b) 198)) + (list ?a ?b ?c) "abz") + nil))) + +(ert-deftest cl-extra-test-notany () + (should (equal (cl-notany #'oddp '(1 3 5)) nil)) + (should (equal (cl-notany #'oddp '(2 4 6)) t)) + (should (equal (cl-notany #'oddp '(1 2 3 4 5)) nil))) + +(ert-deftest cl-extra-test-notevery () + (should (equal (cl-notevery #'oddp '(1 3 5)) nil)) + (should (equal (cl-notevery #'oddp '(2 4 6)) t)) + (should (equal (cl-notevery #'oddp '(1 2 3 4 5)) t))) + +(ert-deftest cl-extra-test-gcd () + (should (equal (cl-gcd 4) 4)) + (should (equal (cl-gcd 3 5) 1)) + (should (equal (cl-gcd 4 8) 4)) + (should (equal (cl-gcd 3 5 7) 1)) + (should (equal (cl-gcd 4 8 12) 4)) + (should (equal (cl-gcd 0) 0)) + (should (equal (cl-gcd 4 0) 4)) + (should (equal (cl-gcd 0 0) 0))) + +(ert-deftest cl-extra-test-lcm () + (should (equal (cl-lcm 4) 4)) + (should (equal (cl-lcm 3 5) 15)) + (should (equal (cl-lcm 4 8) 8)) + (should (equal (cl-lcm 3 5 7) 105)) + (should (equal (cl-lcm 4 8 12) 24)) + (should (equal (cl-lcm 0 4) 0)) + (should (equal (cl-lcm 0 0) 0)) + (should (equal (cl-lcm) 1))) + +(ert-deftest cl-extra-test-isqrt () + (should (equal (cl-isqrt 4) 2)) + (should (equal (cl-isqrt 100) 10)) + (should (equal (cl-isqrt 1) 1)) + (should (equal (cl-isqrt 0) 0)) + (should (equal (cl-isqrt 3) 1)) + (should (equal (cl-isqrt 10) 3)) + (should-error (cl-isqrt -4)) + (should-error (cl-isqrt 2.5))) + +(ert-deftest cl-extra-test-floor () + (should (equal (cl-floor 4.5) '(4 0.5))) + (should (equal (cl-floor 10 3) '(3 1)))) + +(ert-deftest cl-extra-test-ceiling () + (should (equal (cl-ceiling 4.5) '(5 -0.5))) + (should (equal (cl-ceiling 10 3) '(4 -2)))) + +(ert-deftest cl-extra-test-truncate () + (should (equal (cl-truncate 4.5) '(4 0.5))) + (should (equal (cl-truncate 10 3) '(3 1)))) + +(ert-deftest cl-extra-test-round () + (should (equal (cl-round 4.5) '(4 0.5))) + (should (equal (cl-round 10 3) '(3 1))) + (should (equal (cl-round 1.5) '(2 -0.5))) + (should (equal (cl-round 2.5) '(2 0.5)))) + +(ert-deftest cl-extra-test-mod () + (should (equal (cl-mod 10 3) 1)) + (should (equal (cl-mod -10 -3) -1)) + (should (equal (cl-mod -10 3) 2)) + (should (equal (cl-mod 10 -3) -2))) + +(ert-deftest cl-extra-test-rem () + (should (equal (cl-rem 10 3) 1)) + (should (equal (cl-rem -10 -3) -1)) + (should (equal (cl-rem -10 3) -1)) + (should (equal (cl-rem 10 -3) 1))) + +(ert-deftest cl-extra-test-signum () + (should (equal (cl-signum 10) 1)) + (should (equal (cl-signum -10) -1)) + (should (equal (cl-signum 0) 0))) + +(ert-deftest cl-extra-test-parse-integer () + (should (equal (cl-parse-integer "10") 10)) + (should (equal (cl-parse-integer "-10") -10)) + (should (equal (cl-parse-integer "+10") 10)) + (should (equal (cl-parse-integer "ff" :radix 16) 255)) + (should (equal (cl-parse-integer "11" :start 1) 1)) + (should (equal (cl-parse-integer "abc def" :end 3 :junk-allowed t) nil))) + +(ert-deftest cl-extra-test-subseq () + (should (equal (cl-subseq "hello" 1) "ello")) + (should (equal (cl-subseq "hello" 1 4) "ell")) + (should (equal (cl-subseq "hello" -1) "o")) + (should (equal (cl-subseq "hello world" -5 -1) "worl")) + (should (equal (cl-subseq '(1 2 3 4 5) 2) '(3 4 5))) + (should (equal (cl-subseq '(1 2 3 4 5) 1 3) '(2 3)))) + +(ert-deftest cl-extra-test-concatenate () + (should (equal (cl-concatenate 'string "hello " "world") "hello world")) + (should (equal (cl-concatenate 'list '(1 2) '(3 4) '(5 6)) '(1 2 3 4 5 6)))) + +(ert-deftest cl-extra-test-revappend () + (should (equal (cl-revappend '(1 2 3) '(4 5 6)) '(3 2 1 4 5 6)))) + +(ert-deftest cl-extra-test-nreconc () + (should (equal (cl-nreconc '(1 2 3) '(4 5 6)) '(3 2 1 4 5 6)))) + +(ert-deftest cl-extra-test-list-length () + (should (equal (cl-list-length '(1 2 3)) 3)) + (should (equal (cl-list-length '()) 0)) + (let ((xl (number-sequence 1 100))) + (setcdr (nthcdr 99 xl) xl) + (should (equal (cl-list-length xl) nil)))) + +(ert-deftest cl-extra-test-tailp () + (let ((l '(1 2 3 4 5))) + (should (cl-tailp (nthcdr 2 l) l)) + (should (cl-tailp l l)) + (should (not (cl-tailp '(4 5) l))))) + +(ert-deftest cl-extra-test-remprop () + (let ((sym (make-symbol "test"))) + (put sym 'foo 'bar) + (should (equal (cl-get sym 'foo) 'bar)) + (cl-remprop sym 'foo) + (should (equal (cl-get sym 'foo 'default) 'default)))) + ;;; cl-extra-tests.el ends here diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index a9c71fa5808..ff860d94468 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -242,6 +242,42 @@ (should (= (cl-the integer (cl-incf side-effect)) 1)) (should (= side-effect 1)))) +(ert-deftest cl-lib-test-pushnew () + (let ((list '(1 2 3))) + (cl-pushnew 0 list) + (should (equal list '(0 1 2 3)))) + (let ((list '((1 2) (3 4)))) + (cl-pushnew '(3 7) list :key #'cdr) + (should (equal list '((3 7) (1 2) (3 4)) ))) + (let ((list '((1 2) (3 4)))) + (cl-pushnew '(3 7) list :key #'car) + (should (equal list '((1 2) (3 4))))) + (let ((list '((1 2) (3 4)))) + (cl-pushnew '(3 4) list :test #'equal) + (should (equal list '((1 2) (3 4))))) + (let ((list '((1 2) (3 4)))) + (cl-pushnew '(3 5) list :test #'equal) + (should (equal list '((3 5) (1 2) (3 4))))) + (let ((list '((1 2) (3 4)))) + (cl-pushnew '(3 4) list :test-not #'equal) + (should (equal list '((1 2) (3 4))))) + (let ((list '((1 2) (3 4)))) + (cl-pushnew '(3 5) list :test-not #'equal) + (should (equal list '((1 2) (3 4)))))) + +(ert-deftest cl-lib-test-values-list () + (let ((list '(:a :b :c))) + (should (equal (cl-values-list list) '(:a :b :c)))) + (let ((not-a-list :a)) + (should-error (cl-values-list not-a-list) :type 'wrong-type-argument))) + +(ert-deftest cl-lib-multiple-value-list () + (should (equal (cl-multiple-value-list 1) 1)) + (should (equal (cl-multiple-value-list '(1 2 3)) '(1 2 3))) + (should (equal (cl-multiple-value-list "string") "string")) + (should (equal (cl-multiple-value-list nil) nil)) + (should (equal (cl-multiple-value-list (list 1 2 3)) '(1 2 3)))) + (ert-deftest cl-lib-test-incf () (let ((var 0)) (should (= (cl-incf var) 1)) @@ -388,6 +424,50 @@ (should (= 10 (cl-tenth '(1 2 3 4 5 6 7 8 9 10 11)))) (should-error (cl-tenth "1234567890") :type 'wrong-type-argument)) +(ert-deftest cl-lib-test-mapcar () + (should (equal (cl-mapcar #'1+ '(1 2 3)) '(2 3 4))) + (should (equal (cl-mapcar #'+ '(1 2 3) '(4 5 6)) '(5 7 9))) + (should (equal (cl-mapcar #'+ '(1 2 3) '(4 5)) '(5 7))) + (should (equal (cl-mapcar #'+ '() '()) '())) + (should-error (cl-mapcar #'+ 1 '(4 5 6))) + (should-error (cl-mapcar #'+ '(1 2 3) 4))) + +(ert-deftest cl-lib-test-list* () + (should (equal (cl-list* 'a) 'a)) + (should (equal (cl-list* 'a 'b) '(a . b))) + (should (equal (cl-list* 'a 'b 'c 'd) '(a b c . d))) + (should (equal (cl-list* 'a 'b '(c d)) '(a b c d)))) + +(ert-deftest cl-lib-test-copy-list () + (let ((original '(1 2 . 3)) + (result (cl-copy-list '(1 2 . 3)))) + (and (should (equal original result)) + (not (eq original result))))) + +(ert-deftest cl-lib-test-subst () + (should (equal (cl-subst 'x 'a '(a b c)) '(x b c))) + (should (equal (cl-subst 'x 'a '(a b a c)) '(x b x c))) + (should (equal (cl-subst 'x 'a '(b c d)) '(b c d))) + (should (equal (cl-subst 'x 'a '(a b (a c) d)) '(x b (x c) d))) + (should (equal (cl-subst "a" "A" '("a" "b" "c" "a") :test #'equal) '("a" "b" "c" "a")))) + +(ert-deftest cl-lib-test-acons () + (should (equal (cl-acons 'key 'value '()) '((key . value)))) + (should (equal (cl-acons 'key 'value '((a . 1) (b . 2))) '((key . value) (a . 1) (b . 2)))) + (should (equal (cl-acons 'a 1 '((a . 1) (b . 2))) '((a . 1) (a . 1) (b . 2)))) + (should (equal (cl-acons nil 'value '((a . 1) (b . 2))) '((nil . value) (a . 1) (b . 2)))) + (should (equal (cl-acons 'key nil '((a . 1) (b . 2))) '((key . nil) (a . 1) (b . 2))))) + +(ert-deftest cl-lib-test-pairlis () + (should (equal (cl-pairlis '(a b c) '(1 2 3)) '((a . 1) (b . 2) (c . 3)))) + (should (equal (cl-pairlis '(a b c d) '(1 2 3)) '((a . 1) (b . 2) (c . 3)))) + (should (equal (cl-pairlis '(a b c) '(1 2 3 4)) '((a . 1) (b . 2) (c . 3)))) + (should (equal (cl-pairlis '(a b c) '(1 2 3) '((d . 4) (e . 5))) '((a . 1) (b . 2) (c . 3) (d . 4) (e . 5)))) + (should (equal (cl-pairlis '() '(1 2 3)) '())) + (should (equal (cl-pairlis '(a b c) '()) '())) + (should (equal (cl-pairlis '(a nil c) '(1 2 3)) '((a . 1) (nil . 2) (c . 3)))) + (should (equal (cl-pairlis '(a b c) '(1 nil 3)) '((a . 1) (b) (c . 3))))) + (ert-deftest cl-lib-test-endp () (should (cl-endp '())) (should-not (cl-endp '(1))) @@ -558,5 +638,37 @@ (should (equal (mapcar (cl-constantly 3) '(a b c d)) '(3 3 3 3)))) +(ert-deftest cl-lib-set-difference () + ;; our set-difference preserves order, though it is not required to + ;; by cl standards. Nevertheless better keep that invariant + (should (equal (cl-set-difference '(1 2 3 4) '(3 4 5 6)) + '(1 2)))) + +(ert-deftest cl-nset-difference () + ;; our nset-difference doesn't + (let* ((l1 (list 1 2 3 4)) (l2 '(3 4 5 6)) + (diff (cl-nset-difference l1 l2))) + (should (memq 1 diff)) + (should (memq 2 diff)) + (should (= (length diff) 2)) + (should (equal l2 '(3 4 5 6)))) + (let* ((l1 (list "1" "2" "3" "4")) (l2 '("3" "4" "5" "6")) + (diff (cl-nset-difference l1 l2 :test #'equal))) + (should (member "1" diff)) + (should (member "2" diff)) + (should (= (length diff) 2)) + (should (equal l2 '("3" "4" "5" "6")))) + (let* ((l1 (list '(a . 1) '(b . 2) '(c . 3) '(d . 4))) + (l2 (list '(c . 3) '(d . 4) '(e . 5) '(f . 6))) + (diff (cl-nset-difference l1 l2 :key #'car))) + (should (member '(a . 1) diff)) + (should (member '(b . 2) diff)) + (should (= (length diff) 2))) + (let* ((l1 (list '("a" . 1) '("b" . 2) '("c" . 3) '("d" . 4))) + (l2 (list '("c" . 3) '("d" . 4) '("e" . 5) '("f" . 6))) + (diff (cl-nset-difference l1 l2 :key #'car :test #'string=))) + (should (member '("a" . 1) diff)) + (should (member '("b" . 2) diff)) + (should (= (length diff) 2)))) ;;; cl-lib-tests.el ends here diff --git a/test/lisp/emacs-lisp/cl-seq-tests.el b/test/lisp/emacs-lisp/cl-seq-tests.el index 9c62379d857..59ece0e4006 100644 --- a/test/lisp/emacs-lisp/cl-seq-tests.el +++ b/test/lisp/emacs-lisp/cl-seq-tests.el @@ -59,6 +59,22 @@ Body are forms defining the test." (when ,list2 (setq cl-seq--test-list2 ,orig2)))))) +(ert-deftest cl-seq-endp-test () + (should (cl-endp '())) + (should (not (cl-endp '(1 2 3)))) + (should-error (cl-endp 42) :type 'wrong-type-argument)) + +(ert-deftest cl-seq-reduce-test () + (should (equal 6 (cl-reduce #'+ '(1 2 3)))) + (should (equal 5 (cl-reduce #'+ '(1 2 3 4) :start 1 :end 3))) + (should (equal 10 (cl-reduce #'+ '(1 2 3 4) :from-end t))) + (should (equal 10 (cl-reduce #'+ '(1 2 3 4) :initial-value 0))) + (should (equal 24 (cl-reduce #'* '(1 2 3 4) :initial-value 1))) + (should (equal 0 (cl-reduce #'+ '()))) + (should (equal 0 (cl-reduce #'+ '() :initial-value 0))) + (should (equal 1 (cl-reduce #'+ '(1)))) + (should (equal 0 (cl-reduce #'+ '() :initial-value 0)))) + ;; keywords supported: :start :end (ert-deftest cl-seq-fill-test () (let* ((cl-seq--test-list '(1 2 3 4 5 2 6)) @@ -116,6 +132,25 @@ Body are forms defining the test." (should (equal '(1 3 4 5 2 6) (cl-remove 2 list :from-end nil :count 1))) (should (equal '(1 2 3 4 5 6) (cl-remove 2 list :from-end t :count 1))))) +(ert-deftest cl-remove-if-test () + (should (equal '(1 3) (cl-remove-if 'evenp '(1 2 3 4)))) + (should (equal '(1 3) (cl-remove-if 'evenp '(1 2 3 4) :count 2))) + (should (equal '(1 3 4) (cl-remove-if 'evenp '(1 2 3 4) :start 1 :end 3))) + (should (equal '(1 3) (cl-remove-if 'evenp '(1 2 3 4) :from-end t))) + (should (equal '(2 4) (cl-remove-if 'oddp '(1 2 3 4)))) + (should (equal '() (cl-remove-if 'evenp '()))) + (should (equal '() (cl-remove-if 'evenp '(2))))) + +(ert-deftest cl-remove-if-not-test () + (should (equal '(2 4) (cl-remove-if-not 'evenp '(1 2 3 4)))) + (should (equal '(2 4) (cl-remove-if-not 'evenp '(1 2 3 4) :count 2))) + (should (equal '(1 2 4) (cl-remove-if-not 'evenp '(1 2 3 4) :start 1 :end 3))) + (should (equal '(2 4) (cl-remove-if-not 'evenp '(1 2 3 4) :from-end t))) + (should (equal '(1 3) (cl-remove-if-not 'oddp '(1 2 3 4)))) + (should (equal '() (cl-remove-if-not 'evenp '()))) + (should (equal '(2) (cl-remove-if-not 'evenp '(2)))) + (should (equal '(2) (cl-remove-if-not 'evenp '(2) :key #'(lambda (x) (- x)))))) + ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-delete-test () (let* ((cl-seq--test-list '(1 2 3 4 5 2 6)) @@ -139,6 +174,27 @@ Body are forms defining the test." (cl-seq--with-side-effects orig nil test))))) +(ert-deftest cl-delete-if-test () + (let ((list (list 1 2 3 4 5))) + (cl-delete-if 'evenp list) + (should (equal '(1 3 5) list)) + (should (equal '(1 3 5) (cl-delete-if 'evenp (list 1 2 3 4 5) :start 0 :end 4))) + (should (equal '(1 3 5) (cl-delete-if 'evenp (list 1 2 3 4 5) :from-end t))) + (should (equal '(2 4) (cl-delete-if 'oddp (list 1 2 3 4 5)))) + (should (equal '() (cl-delete-if 'evenp '()))) + (should (equal '() (cl-delete-if 'evenp (list 2)))))) + +(ert-deftest cl-delete-if-not-test () + (let ((list (list 1 2 3 4 5))) + (should (equal '(2 4) (cl-delete-if-not 'evenp list))) + (should (equal '() (cl-delete-if-not 'evenp '()))) + (should (equal '() (cl-delete-if-not 'evenp (list 1)))))) + +(ert-deftest cl-delete-duplicates-test () + (let ((list (list 1 2 3 2 1))) + (should (equal '(3 2 1) (cl-delete-duplicates list))) + (should (equal '() (cl-delete-duplicates '()))))) + ;; keywords supported: :test :test-not :key :start :end :from-end (ert-deftest cl-seq-remove-duplicates-test () (let ((list '(1 2 3 4 5 2 6))) @@ -185,6 +241,65 @@ Body are forms defining the test." (should (equal '(b 2 3 4 5 2 6) (cl-substitute 'b nil list :if-not (lambda (x) (> (cl-position x list :from-end t) 1))))))) +(ert-deftest cl-seq-substitute-if-test () + (let ((result (cl-substitute-if 'x #'evenp '(1 2 3 4 5)))) + (should (equal result '(1 x 3 x 5)))) + (let ((result (cl-substitute-if 'x #'evenp '(1 3 5)))) + (should (equal result '(1 3 5)))) + (let ((result (cl-substitute-if 'x #'(lambda (n) t) '(1 2 3 4 5)))) + (should (equal result '(x x x x x)))) + (let ((result (cl-substitute-if 'x #'evenp '(1 2 3 4 5) :start 1 :end 4))) + (should (equal result '(1 x 3 x 5)))) + (let ((result (cl-substitute-if 'x #'oddp '(1 2 3 4 5) :from-end t))) + (should (equal result '(x 2 x 4 x)))) + (let ((result (cl-substitute-if 'x (lambda (n) (= n 3)) '(1 2 3 4 5) :key 'identity))) + (should (equal result '(1 2 x 4 5))))) + +(ert-deftest cl-seq-substitute-if-not-test () + (let ((result (cl-substitute-if-not 'x #'evenp '(1 2 3 4 5)))) + (should (equal result '(x 2 x 4 x)))) + (let ((result (cl-substitute-if-not 'x #'evenp '(2 4 6)))) + (should (equal result '(2 4 6)))) + (let ((result (cl-substitute-if-not 'x #'(lambda (n) (> n 5)) '(1 2 3 4 5)))) + (should (equal result '(x x x x x)))) + (let ((result (cl-substitute-if-not 'x #'evenp '(1 2 3 4 5) :start 0 :end 4))) + (should (equal result '(x 2 x 4 5)))) + (let ((result (cl-substitute-if-not 'x #'oddp '(1 2 3 4 5) :from-end t))) + (should (equal result '(1 x 3 x 5)))) + (let ((result (cl-substitute-if-not 'x (lambda (n) (= n 3)) '(1 2 3 4 5) :key 'identity))) + (should (equal result '(x x 3 x x))))) + +(ert-deftest cl-find-if-test () + (let ((result (cl-find-if #'evenp '(1 2 3 4 5)))) + (should (equal result 2))) + (let ((result (cl-find-if #'(lambda (n) (> n 5)) '(1 2 3 4 5)))) + (should (equal result nil))) + (let ((result (cl-find-if #'(lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) + (should (equal result 4))) + (let ((result (cl-find-if #'evenp '(1 2 3 4 5) :start 2))) + (should (equal result 4))) + (let ((result (cl-find-if #'evenp '(1 2 3 4 5) :end 1))) + (should (equal result nil))) + (let ((result (cl-find-if #'oddp '(2 4 5 6 7) :from-end t))) + (should (equal result 7))) + (let ((result (cl-find-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key 'identity))) + (should (equal result 4)))) + +(ert-deftest cl-find-if-not-test () + (let ((result (cl-find-if-not #'evenp '(1 2 3 4 5)))) + (should (equal result 1))) + (let ((result (cl-find-if-not #'oddp '(1 3 5)))) + (should (equal result nil))) + (let ((result (cl-find-if-not #'(lambda (n) (< n 4)) '(1 2 3 4 5 6 7)))) + (should (equal result 4))) + (let ((result (cl-find-if-not #'evenp '(1 2 3 4 5) :start 2))) + (should (equal result 3))) + (let ((result (cl-find-if-not #'evenp '(1 2 3 4 5) :end 3))) + (should (equal result 1))) + (let ((result (cl-find-if-not #'oddp '(2 4 6 7 8) :from-end t))) + (should (equal result 8))) + (let ((result (cl-find-if-not (lambda (n) (= n 4)) '(1 2 3 4 5) :key 'identity))) + (should (equal result 1)))) ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-nsubstitute-test () @@ -221,7 +336,7 @@ Body are forms defining the test." (dolist (test tests) (let ((_list cl-seq--test-list)) (cl-seq--with-side-effects orig nil - test))))) + test))))) ;; keywords supported: :test :test-not :key :start :end :from-end (ert-deftest cl-seq-position-test () @@ -241,6 +356,22 @@ Body are forms defining the test." (should (= 1 (cl-position 5 list :key (lambda (x) (1+ (* x x)))))) (should (= 5 (cl-position 5 list :key (lambda (x) (1+ (* x x))) :from-end t))))) +(ert-deftest cl-position-if-test () + (let ((result (cl-position-if #'evenp '(1 2 3 4 5)))) + (should (equal result 1))) + (let ((result (cl-position-if #'(lambda (n) (> n 5)) '(1 2 3 4 5)))) + (should (equal result nil))) + (let ((result (cl-position-if #'(lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) + (should (equal result 3))) + (let ((result (cl-position-if #'evenp '(1 2 3 4 5) :start 2))) + (should (equal result 3))) + (let ((result (cl-position-if #'evenp '(1 2 3 4 5) :end 1))) + (should (equal result nil))) + (let ((result (cl-position-if #'oddp '(2 4 5 6 7) :from-end t))) + (should (equal result 4))) + (let ((result (cl-position-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key 'identity))) + (should (equal result 3)))) + ;; keywords supported: :test :test-not :key :start :end (ert-deftest cl-seq-count-test () (let ((list '(1 2 3 4 5 2 6))) @@ -254,6 +385,50 @@ Body are forms defining the test." (should (equal (cl-count 'foo list :test (lambda (_a b) (cl-oddp b))) (cl-count 'foo list :test-not (lambda (_a b) (cl-evenp b))))))) +(ert-deftest cl-count-if-test () + (let ((result (cl-count-if #'evenp '(1 2 3 4 5)))) + (should (equal result 2))) + (let ((result (cl-count-if #'oddp '(2 4 6 8)))) + (should (equal result 0))) + (let ((result (cl-count-if (lambda (x) t) '(1 2 3 4)))) + (should (equal result 4))) + (let ((result (cl-count-if (lambda (x) nil) '(1 2 3 4)))) + (should (equal result 0))) + (let ((result (cl-count-if #'(lambda (x) (> x 2)) '(1 2 3 4 5) :key 'identity))) + (should (equal result 3))) + (let ((result (cl-count-if #'evenp '(1 2 3 4 5) :start 2))) + (should (equal result 1))) + (let ((result (cl-count-if #'evenp '(1 2 3 4 5) :end 3))) + (should (equal result 1))) + (let ((result (cl-count-if #'evenp '()))) + (should (equal result 0))) + (let ((result (cl-count-if #'(lambda (x) (numberp x)) '(1 "two" 3 4 "five" 6)))) + (should (equal result 4))) + (let ((result (cl-count-if (lambda (x) (and (numberp x) (> x 2))) '(1 2 3 4 5 6)))) + (should (equal result 4)))) + +(ert-deftest cl-count-if-not-test () + (let ((result (cl-count-if-not #'evenp '(1 2 3 4 5)))) + (should (equal result 3))) + (let ((result (cl-count-if-not #'oddp '(1 3 5)))) + (should (equal result 0))) + (let ((result (cl-count-if-not (lambda (x) t) '(1 2 3 4)))) + (should (equal result 0))) + (let ((result (cl-count-if-not (lambda (x) nil) '(1 2 3 4)))) + (should (equal result 4))) + (let ((result (cl-count-if-not #'(lambda (x) (> x 3)) '(1 2 3 4 5) :key 'identity))) + (should (equal result 3))) + (let ((result (cl-count-if-not #'evenp '(1 2 3 4 5) :start 2))) + (should (equal result 2))) + (let ((result (cl-count-if-not #'evenp '(1 2 3 4 5) :end 3))) + (should (equal result 2))) + (let ((result (cl-count-if-not #'evenp '()))) + (should (equal result 0))) + (let ((result (cl-count-if-not #'(lambda (x) (numberp x)) '(1 "two" 3 4 "five" 6)))) + (should (equal result 2))) + (let ((result (cl-count-if-not (lambda (x) (and (numberp x) (> x 2))) '(1 2 3 4 5 6)))) + (should (equal result 2)))) + ;; keywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end (ert-deftest cl-seq-mismatch-test () (let ((list '(1 2 3 4 5 2 6)) @@ -312,5 +487,536 @@ Body are forms defining the test." (should (eq (cl-assoc x a) (car a))) (should (eq (cl-rassoc x a) (cadr a)))))) +(ert-deftest cl-sort-test () + (let ((result (cl-sort '(3 1 4 1 5 9 2 6 5 3 5) '<))) + (should (equal result '(1 1 2 3 3 4 5 5 5 6 9)))) + (let ((result (cl-sort '(5 3 2 8 1 4) '>))) + (should (equal result '(8 5 4 3 2 1)))) + (let ((result (cl-sort '("banana" "apple" "cherry") 'string<))) + (should (equal result '("apple" "banana" "cherry")))) + (let ((result (cl-sort '("banana" "fig" "apple" "kiwi") (lambda (x y) (< (length x) (length y))) :key 'identity))) + (should (equal result '("fig" "kiwi" "apple" "banana")))) + (let ((result (cl-sort (vector 3 1 4 1 5) '<))) + (should (equal result (vector 1 1 3 4 5)))) + (let ((result (cl-sort '(1 2 3 4 5) '<))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-sort '(-3 1 4 -1 -5 9) '<))) + (should (equal result '(-5 -3 -1 1 4 9)))) + (let ((result (cl-sort '(1 2 3 4 5) (lambda (x y) (> x y))))) + (should (equal result '(5 4 3 2 1)))) + (let ((result (cl-sort '() '<))) + (should (equal result '()))) + (let ((result (cl-sort '("Banana" "apple" "cherry") 'string< :key 'downcase))) + (should (equal result '("apple" "Banana" "cherry")))) ) + +(ert-deftest cl-stable-sort-test () + (let ((result (cl-stable-sort '(3 1 4 1 5 9 2 6 5 3 5) '<))) + (should (equal result '(1 1 2 3 3 4 5 5 5 6 9)))) + (let ((result (cl-stable-sort '(5 3 2 8 1 4) '>))) + (should (equal result '(8 5 4 3 2 1)))) + (let ((result (cl-stable-sort '("banana" "apple" "cherry") 'string<))) + (should (equal result '("apple" "banana" "cherry")))) + (let ((result (cl-stable-sort '("banana" "fig" "apple" "kiwi") (lambda (x y) (< (length x) (length y))) :key 'identity))) + (should (equal result '("fig" "kiwi" "apple" "banana")))) + (let ((result (cl-stable-sort (vector 3 1 4 1 5) '<))) + (should (equal result (vector 1 1 3 4 5)))) + (let ((result (cl-stable-sort '(1 2 3 4 5) '<))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-stable-sort '(-3 1 4 -1 -5 9) '<))) + (should (equal result '(-5 -3 -1 1 4 9)))) + (let ((result (cl-stable-sort '(1 2 3 4 5) (lambda (x y) (> x y))))) + (should (equal result '(5 4 3 2 1)))) + (let ((result (cl-stable-sort '() '<))) + (should (equal result '()))) + (let ((result (cl-stable-sort '("Banana" "apple" "cherry") 'string< :key 'downcase))) + (should (equal result '("apple" "Banana" "cherry")))) ) + +(ert-deftest cl-merge-test () + (let ((result (cl-merge 'list '(1 3 5) '(2 4 6) '<))) + (should (equal result '(1 2 3 4 5 6)))) + (let ((result (cl-merge 'list '(1 3 3 5) '(2 3 4 6) '<))) + (should (equal result '(1 2 3 3 3 4 5 6)))) + (let ((result (cl-merge 'list '() '(2 4 6) '<))) + (should (equal result '(2 4 6)))) + (let ((result (cl-merge 'list '(1 3 5) '() '<))) + (should (equal result '(1 3 5)))) + (let ((result (cl-merge 'list '() '() '<))) + (should (equal result '()))) + (let ((result (cl-merge 'list '(1 4 6) '(2 3 5) '< :key (lambda (x) x)))) + (should (equal result '(1 2 3 4 5 6)))) + (let ((result (cl-merge 'vector (vector 1 3 5) (vector 2 4 6) '<))) + (should (equal result (vector 1 2 3 4 5 6)))) + (let ((result (cl-merge 'list '(5 3 1) '(6 4 2) '>))) + (should (equal result '(6 5 4 3 2 1)))) + (let ((result (cl-merge 'list '(1 2 3) '(1 2 3) '>))) + (should (equal result '(1 2 3 1 2 3)))) + (let ((result (cl-merge 'list '(1 2) '(3 4 5) '<))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-merge 'list '(4 5 6) '(1 2 3) '<))) + (should (equal result '(1 2 3 4 5 6)))) + (let ((result (cl-merge 'list '(1 2 3) '(1.5 2.5 3.5) '<))) + (should (equal result '(1 1.5 2 2.5 3 3.5)))) + (let ((result (cl-merge 'list '(1 2 3) '(10 20 30) '< :key (lambda (x) (* x 10))))) + (should (equal result '(1 2 3 10 20 30))))) + +(ert-deftest cl-member-test () + (let ((result (cl-member 'b '(a b c d)))) + (should (equal result '(b c d)))) + (let ((result (cl-member 'x '(a b c d)))) + (should (equal result nil))) + (let ((result (cl-member 'a '(a b a c d)))) + (should (equal result '(a b a c d)))) + (let ((result (cl-member "test" '("test" "not-test" "test2") :test 'string=))) + (should (equal result '("test" "not-test" "test2")))) + (let ((result (cl-member 'x '(a b c d) :test-not 'eq))) + (should (equal result '(a b c d)))) + (let ((result (cl-member 3 '(1 2 3 4 5) :key 'identity))) + (should (equal result '(3 4 5)))) + (let ((result (cl-member 2.5 '(1 2 2.5 3) :test 'equal))) + (should (equal result '(2.5 3)))) + (let ((result (cl-member 'a '(a a a a) :test 'eq))) + (should (equal result '(a a a a)))) + (let ((result (cl-member 'a '()))) + (should (equal result nil))) + (let ((result (cl-member 'b '(a c d) :test-not 'eq))) + (should (equal result '(a c d)))) + (let ((result (cl-member 3 '(1 2 3 4 5) :key '1+))) + (should (equal result '(2 3 4 5))))) + +(ert-deftest cl-member-if-test () + (let ((result (cl-member-if #'evenp '(1 2 3 4 5)))) + (should (equal result '(2 3 4 5)))) + (let ((result (cl-member-if #'(lambda (x) nil) '(1 2 3 4 5)))) + (should (equal result nil))) + (let ((result (cl-member-if #'(lambda (x) t) '(1 2 3 4 5)))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-member-if #'(lambda (x) (= x 1)) '(1 2 3 4 5)))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-member-if #'(lambda (x) (and (numberp x) (evenp x))) '(1 3 5 4 2)))) + (should (equal result '(4 2)))) + (let ((result (cl-member-if (lambda (x) (string= (number-to-string x) "3")) '(1 2 3 4 5) :key 'identity))) + (should (equal result '(3 4 5)))) + (let ((result (cl-member-if #'(lambda (x) (eq x 'a)) '(a a a a)))) + (should (equal result '(a a a a)))) + (let ((result (cl-member-if #'evenp '()))) + (should (equal result nil))) + (let ((result (cl-member-if #'(lambda (x) (< x 0)) '(1 2 3 4 5)))) + (should (equal result nil))) + (let ((result (cl-member-if (lambda (x) (and (numberp x) (<= x 2))) '(1 "two" 3 0)))) + (should (equal result '(1 "two" 3 0)))) + (let ((result (cl-member-if (lambda (x) (> x 5)) '(1 2 3 6 7 8) :key 'identity))) + (should (equal result '(6 7 8))))) + +(ert-deftest cl-member-if-not-test () + (let ((result (cl-member-if-not #'evenp '(1 2 3 4 5)))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'evenp '(2 4 6 8 10 11)))) + (should (equal result '(11)))) + (let ((result (cl-member-if-not #'(lambda (x) (> x 5)) '(1 2 3 4 5)))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'(lambda (x) t) '(1 2 3 4 5)))) + (should (equal result nil))) + (let ((result (cl-member-if-not #'(lambda (x) (= x 1)) '(1 2 3 4 5)))) + (should (equal result '(2 3 4 5)))) + (let ((result (cl-member-if-not (lambda (x) (string= (number-to-string x) "2")) '(1 2 3 4 5) :key 'identity))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'evenp '()))) + (should (equal result nil))) + (let ((result (cl-member-if-not #'(lambda (x) (eq x 'a)) '(a a a a)))) + (should (equal result nil))) + (let ((result (cl-member-if-not #'(lambda (x) (< x 0)) '(1 2 3 4 5)))) + (should (equal result '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'(lambda (x) (or (numberp x) (stringp x) (eq x 'b))) '(a "b" 3 nil)))) + (should (equal result '(a "b" 3 nil)))) + (let ((result (cl-member-if-not (lambda (x) (numberp x)) '(1 "two" 3 "four" 5) :key 'identity))) + (should (equal result '("two" 3 "four" 5))))) + +(ert-deftest cl-assoc-test () + (let ((result (cl-assoc 'b '((a . 1) (b . 2) (c . 3))))) + (should (equal result '(b . 2)))) + (let ((result (cl-assoc 'x '((a . 1) (b . 2) (c . 3))))) + (should (equal result nil))) + (let ((result (cl-assoc "key" '(("key" . 1) ("not-key" . 2)) :test 'string=))) + (should (equal result '("key" . 1)))) + (let ((result (cl-assoc 'a '((a . 1) (b . 2) (c . 3)) :test-not 'eq))) + (should (equal result '(b . 2)))) + (let ((result (cl-assoc '2 '((1 . 'a) (2 . 'b) (3 . 'c)) :key 'identity))) + (should (equal result '(2 . 'b)))) + (let ((result (cl-assoc 'a '((a . 1) (a . 2) (a . 3)) :test 'eq))) + (should (equal result '(a . 1)))) + (let ((result (cl-assoc 'a '()))) + (should (equal result nil))) + (let ((result (cl-assoc 'b '((a . 1) (b . 2) (b . 3) (c . 4))))) + (should (equal result '(b . 2))))) + +(ert-deftest cl-assoc-if-test () + (let ((result (cl-assoc-if #'evenp '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))))) + (should (equal result '(2 . "even")))) + (let ((result (cl-assoc-if #'(lambda (x) (= x 5)) '((1 . "one") (2 . "two") (3 . "three"))))) + (should (equal result nil))) + (let ((result (cl-assoc-if #'(lambda (x) (= x 1)) '((1 . "one") (2 . "two") (3 . "three"))))) + (should (equal result '(1 . "one")))) + (let ((result (cl-assoc-if #'(lambda (x) (string= x "baz")) '((foo . 1) (bar . 2) (baz . 3))))) + (should (equal result '(baz . 3)))) + (let ((result (cl-assoc-if (lambda (x) (and (numberp x) (> x 2))) '((1 . "one") (3 . "three") (4 . "four"))))) + (should (equal result '(3 . "three")))) + (let ((result (cl-assoc-if #'(lambda (x) (> x 1)) '((0 . "zero") (1 . "one") (2 . "two"))))) + (should (equal result '(2 . "two")))) + (let ((result (cl-assoc-if #'evenp '()))) + (should (equal result nil))) + (let ((result (cl-assoc-if #'(lambda (x) (eq x 'a)) '((a . "first") (a . "second") (b . "third"))))) + (should (equal result '(a . "first")))) + (let ((result (cl-assoc-if #'(lambda (x) (and (symbolp x) (not (eq x 'b)))) '((b . "b") (c . "c") (d . "d"))))) + (should (equal result '(c . "c")))) + (let ((result (cl-assoc-if (lambda (x) (and (listp x) (> (length x) 1))) '(((1 2) . "pair 1") ((1) . "pair 2"))))) + (should (equal result '((1 2) . "pair 1"))))) + +(ert-deftest cl-assoc-if-not-test () + (let ((result (cl-assoc-if-not #'evenp '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))))) + (should (equal result '(1 . "odd")))) + (let ((result (cl-assoc-if-not #'(lambda (x) (> x 0)) '((1 . "one") (2 . "two") (3 . "three"))))) + (should (equal result nil))) + (let ((result (cl-assoc-if-not #'(lambda (x) (< x 5)) '((1 . "one") (2 . "two") (3 . "three"))))) + (should (equal result nil))) + (let ((result (cl-assoc-if-not #'(lambda (x) (= x 1)) '((1 . "one") (2 . "two") (3 . "three"))))) + (should (equal result '(2 . "two")))) + (let ((result (cl-assoc-if-not #'(lambda (x) (string= x "baz")) '((foo . "first") (bar . "second") (baz . "third"))))) + (should (equal result '(foo . "first")))) + (let ((result (cl-assoc-if-not (lambda (x) (and (numberp x) (> x 2))) '((1 . "one") (3 . "three") (4 . "four"))))) + (should (equal result '(1 . "one")))) + (let ((result (cl-assoc-if-not #'(lambda (x) (symbolp x)) '((1 . "one") (b . "bee") (2 . "two"))))) + (should (equal result '(1 . "one")))) + (let ((result (cl-assoc-if-not #'evenp '()))) + (should (equal result nil))) + (let ((result (cl-assoc-if-not #'(lambda (x) (eq x 'a)) '((a . "first") (a . "second") (b . "third"))))) + (should (equal result '(b . "third"))))) + +(ert-deftest cl-rassoc-test () + (let ((result (cl-rassoc 2 '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result (cons "two" 2)))) + (let ((result (cl-rassoc 4 '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result nil))) + (let ((result (cl-rassoc 2 '(( "one" . 1) ("two" . 2) ("baz" . 2)) :test 'equal))) + (should (equal result (cons "two" 2)))) + (let ((result (cl-rassoc 2 '(( "one" . 1) ("two" . 2) ("three" . 3)) :test-not 'equal))) + (should (equal result (cons "one" 1)))) + (let ((result (cl-rassoc 1 '()))) + (should (equal result nil))) + (let ((result (cl-rassoc 1 '(( "first" . 1) ("second" . 1) ("third" . 1))))) + (should (equal result (cons "first" 1)))) + (let ((result (cl-rassoc 3 '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result (cons "three" 3)))) + (let ((result (cl-rassoc 'found '((( "pair 1") . 1) ( "pair 2" . 2) ( "pair 3" . 3))))) + (should (equal result nil)))) + +(ert-deftest cl-rassoc-if-test () + (let ((result (cl-rassoc-if #'evenp '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("two" . 2)))) + (let ((result (cl-rassoc-if #'evenp '(( "one" . 1) ("three" . 3) ("five" . 5))))) + (should (equal result nil))) + (let ((result (cl-rassoc-if #'(lambda (x) (= x 1)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("one" . 1)))) + (let ((result (cl-rassoc-if (lambda (x) (> x 1)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("two" . 2)))) + (let ((result (cl-rassoc-if #'(lambda (x) (and (numberp x) (< x 3))) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("one" . 1)))) + (let ((result (cl-rassoc-if #'evenp '()))) + (should (equal result nil))) + (let ((result (cl-rassoc-if #'(lambda (x) (> x 0)) '(( "first" . 1) ("second" . 2) ("third" . 3))))) + (should (equal result '("first" . 1)))) + (let ((result (cl-rassoc-if #'(lambda (x) (string= (number-to-string x) "two")) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result nil))) + (let ((result (cl-rassoc-if #'(lambda (x) (stringp x)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result nil)))) + +(ert-deftest cl-rassoc-if-not-test () + (let ((result (cl-rassoc-if-not #'evenp '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("one" . 1)))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (> x 0)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result nil))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (< x 5)) '(( "one" . 1) ("two" . 2) ("six" . 6))))) + (should (equal result '( "six" . 6)))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (= x 1)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("two" . 2)))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (> x 2)) '(( "one" . 1) ("two" . 1) ("three" . 3))))) + (should (equal result '("one" . 1)))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (and (numberp x) (< x 3))) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("three" . 3)))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (equal x 2)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result '("one" . 1)))) + (let ((result (cl-rassoc-if-not #'evenp '()))) + (should (equal result nil))) + (let ((result (cl-rassoc-if-not #'(lambda (x) (numberp x)) '(( "one" . 1) ("two" . 2) ("three" . 3))))) + (should (equal result nil))) + (let ((result (cl-rassoc-if-not (lambda (x) (and (listp x) (= (length x) 1))) '(((1 2) . 1) ((3 4) . 2) ((5) . 2))))) + (should (equal result '((1 2) . 1))))) + +(ert-deftest cl-intersection-test () + (let ((result (cl-intersection '(1 2 3 4) '(3 4 5 6)))) + (should (equal result '(4 3)))) + (let ((result (cl-intersection '(1 2) '(3 4)))) + (should (equal result '()))) + (let ((result (cl-intersection '(1 2 3) '(1 2 3)))) + (should (equal result '(1 2 3)))) + (let ((result (cl-intersection '(1 1 2 3) '(1 2 2 3 4)))) + (should (equal result '(3 2 1 1)))) + (let ((result (cl-intersection '(1 "two" 3) '(3 "two" 4)))) + (should (equal result '(3)))) + (let ((result (cl-intersection '(1 2 3) '(3 2 1) :test 'equal))) + (should (equal result '(1 2 3)))) + (let ((result (cl-intersection '(1 2 3) '(3 4 5) :key #'identity))) + (should (equal result '(3)))) + (let ((result (cl-intersection '() '(1 2 3)))) + (should (equal result '()))) + (let ((result (cl-intersection '() '()))) + (should (equal result '()))) + (let ((result (cl-intersection '(1 2 3 4 5) '(3 4 5 6 7 8)))) + (should (equal result '(5 4 3))))) + +(ert-deftest cl-nintersection-test () + (let ((list1 '(1 2 3 4)) + (list2 '(3 4 5 6))) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '(4 3))) + (should (equal list1 '(1 2 3 4))) + (should (equal list2 '(3 4 5 6))))) + (let ((list1 '(1 2)) + (list2 '(3 4))) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '())) + (should (equal list1 '(1 2))) + (should (equal list2 '(3 4))))) + (let ((list1 '(1 2 3)) + (list2 '(1 2 3))) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '(1 2 3))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(1 2 3))))) + (let ((list1 '(1 1 2 2 3)) + (list2 '(2 2 3 4))) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '(3 2 2))) + (should (equal list1 '(1 1 2 2 3))) + (should (equal list2 '(2 2 3 4))))) + (let ((list1 '(1 "two" 3)) + (list2 '(3 "two" 4))) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '(3))) + (should (equal list1 '(1 "two" 3))) + (should (equal list2 '(3 "two" 4))))) + (let ((list1 '(1 2 3)) + (list2 '(3 2 1))) + (let ((result (cl-nintersection list1 list2 :test 'equal))) + (should (equal result '(1 2 3))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 2 1))))) + (let ((list1 '()) + (list2 '(1 2 3))) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '())) + (should (equal list1 '())) + (should (equal list2 '(1 2 3))))) + (let ((list1 '()) + (list2 '())) + (let ((result (cl-nintersection list1 list2))) + (should (equal result '()))))) + +(ert-deftest cl-set-difference-test () + (let ((result (cl-set-difference '(1 2 3 4) '(3 4 5 6)))) + (should (equal result '(1 2)))) + (let ((result (cl-set-difference '(1 2 3) '()))) + (should (equal result '(1 2 3)))) + (let ((result (cl-set-difference '(1 2 3) '(1 2 3)))) + (should (equal result '()))) + (let ((result (cl-set-difference '(1 1 2 3 4) '(3 4 5)))) + (should (equal result '(1 1 2)))) + (let ((result (cl-set-difference '(1 2 3) '(3 2 4)))) + (should (equal result '(1)))) + (let ((result (cl-set-difference '(1 2 3) '(3 2 1) :test 'equal))) + (should (equal result '()))) + (let ((result (cl-set-difference '((1 . "one") (2 . "two") (3 . "three")) + '((1 . "uno") (2 . "dos")) + :key 'car))) + (should (equal result '((3 . "three"))))) + (let ((result (cl-set-difference '() '(1 2 3)))) + (should (equal result '()))) + (let ((result (cl-set-difference '(1 2 3) '()))) + (should (equal result '(1 2 3)))) + (let ((result (cl-set-difference '(1 2 3 4 5) '(3 4 5 6 7)))) + (should (equal result '(1 2)))) + (let ((list1 '(1 2 3)) + (list2 '(2 3 4))) + (cl-set-difference list1 list2) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(2 3 4))))) + +(ert-deftest cl-nset-difference-test () + (let ((list1 '(1 2 3 4)) + (list2 '(3 4 5 6))) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '(1 2))) + (should (equal list1 '(1 2 3 4))) + (should (equal list2 '(3 4 5 6))))) + (let ((list1 '(1 2 3)) + (list2 '())) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '(1 2 3))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '())))) + (let ((list1 '(1 2 3)) + (list2 '(1 2 3))) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '())) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(1 2 3))))) + (let ((list1 '(1 1 2 2 3)) + (list2 '(3 4 5))) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '(1 1 2 2))) + (should (equal list1 '(1 1 2 2 3))) + (should (equal list2 '(3 4 5))))) + (let ((list1 '(1 2 3)) + (list2 '(3 2 4))) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '(1))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 2 4))))) + (let ((list1 '(1 2 3)) + (list2 '(3 2 1))) + (let ((result (cl-nset-difference list1 list2 :test 'equal))) + (should (equal result '())) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 2 1))))) + (let ((list1 '()) + (list2 '(1 2 3))) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '())) + (should (equal list1 '())) + (should (equal list2 '(1 2 3))))) + (let ((list1 '()) + (list2 '())) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '())))) + (let ((list1 '(1 2 3 4 5)) + (list2 '(3 4 5 6 7))) + (let ((result (cl-nset-difference list1 list2))) + (should (equal result '(1 2))) + (should (equal list1 '(1 2 3 4 5))) + (should (equal list2 '(3 4 5 6 7)))))) + +(ert-deftest cl-set-exclusive-or-test () + (let ((result (cl-set-exclusive-or '(1 2 3) '(3 4 5)))) + (should (equal result '(1 2 4 5)))) + (let ((result (cl-set-exclusive-or '(1 2 3) '()))) + (should (equal result '(1 2 3)))) + (let ((result (cl-set-exclusive-or '() '(3 4 5)))) + (should (equal result '(3 4 5)))) + (let ((result (cl-set-exclusive-or '(1 2 3) '(1 2 3)))) + (should (equal result nil))) + (let ((result (cl-set-exclusive-or '(1 1 2 3) '(3 4 5)))) + (should (equal result '(1 1 2 4 5)))) + (let ((result (cl-set-exclusive-or '(1 2 3) '(3 3 4 5)))) + (should (equal result '(1 2 4 5)))) + (let ((result (cl-set-exclusive-or '(1 2 3) '(3 2 4)))) + (should (equal result '(1 4)))) + (let ((result (cl-set-exclusive-or '(1 2 3) '(3 2 1) :test 'equal))) + (should (equal result '()))) + (let ((result (cl-set-exclusive-or '() '()))) + (should (equal result '()))) + (let ((result (cl-set-exclusive-or '(1 2 3 4 5) '(3 4 5 6 7))) + (list1 '(1 2 3 4 5)) + (list2 '(3 4 5 6 7))) + (should (equal result '(1 2 6 7))) + (should (equal list1 '(1 2 3 4 5))) + (should (equal list2 '(3 4 5 6 7))))) + +(ert-deftest cl-nset-exclusive-or-test () + (let ((list1 '(1 2 3)) + (list2 '(3 4 5))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 2 4 5))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 4 5))))) + (let ((list1 '(1 2 3)) + (list2 '())) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 2 3))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '())))) + (let ((list1 '(1 2 3)) + (list2 '(1 2 3))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result nil))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(1 2 3)))) + (let ((list1 '(1 1 2 2 3)) + (list2 '(3 4 5))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 1 2 2 4 5))) + (should (equal list1 '(1 1 2 2 3))) + (should (equal list2 '(3 4 5))))) + (let ((list1 '(1 2 3)) + (list2 '(3 3 4 5))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 2 4 5))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 3 4 5))))) + (let ((list1 '(1 2 3)) + (list2 '(3 2 4))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 4))) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 2 4))))) + (let ((list1 '(1 2 3)) + (list2 '(3 2 1))) + (let ((result (cl-nset-exclusive-or list1 list2 :test 'equal))) + (should (equal result '())) + (should (equal list1 '(1 2 3))) + (should (equal list2 '(3 2 1))))) + (let ((list1 '()) + (list2 '(1 2 3))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 2 3))) + (should (equal list1 '())) + (should (equal list2 '(1 2 3))))) + (let ((list1 '()) + (list2 '())) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '())))) + (let ((list1 '(1 2 3 4 5)) + (list2 '(3 4 5 6 7))) + (let ((result (cl-nset-exclusive-or list1 list2))) + (should (equal result '(1 2 6 7))) + (should (equal list1 '(1 2 3 4 5))) + (should (equal list2 '(3 4 5 6 7)))))) + +(ert-deftest cl-subsetp-test () + (let ((result (cl-subsetp '(1 2) '(1 2 3 4)))) + (should (equal result t))) + (let ((result (cl-subsetp '() '(1 2 3 4)))) + (should (equal result t))) + (let ((result (cl-subsetp '(1 2) '()))) + (should (equal result nil))) + (let ((result (cl-subsetp '(1 2 3) '(1 2 3)))) + (should (equal result t))) + (let ((result (cl-subsetp '(1 1 2) '(1 2 3)))) + (should (equal result t))) + (let ((result (cl-subsetp '(1 2) '(1 1 2 3 4)))) + (should (equal result t))) + (let ((result (cl-subsetp '(1 "two" 3) '(3 "two" 1)))) + (should (equal result nil))) + (let ((result (cl-subsetp '(1 2) '(2 1) :test 'equal))) + (should (equal result t))) + (let ((result (cl-subsetp '((1 . "one") (2 . "two")) '((1 . "uno") (2 . "dos")) :key 'car))) + (should (equal result t))) + (let ((result (cl-subsetp '(1 2) '(3 4 2 1) :test 'eq))) + (should (equal result t))) + (let ((result (cl-subsetp '((1 2) (3)) '((1 2 . "found") (3 . "found")) :key 'car))) + (should (equal result t))) + (let ((result (cl-subsetp '(1 2) '(1 2 3 2)))) + (should (equal result t))) + (let ((result (cl-subsetp '() '()))) + (should (equal result t)))) + (provide 'cl-seq-tests) ;;; cl-seq-tests.el ends here -- 2.41.0 --=-=-=--
Ahmed Khanzada <me@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#75633
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.