diff --git a/tests/scripts/features/double_colon b/tests/scripts/features/double_colon
index cd51ea4..e013f36 100644
--- a/tests/scripts/features/double_colon
+++ b/tests/scripts/features/double_colon
@@ -215,14 +215,23 @@ unlink('joe-is-forced');
 # sv 60188.
 # Even though test.x is explicitly mentioned, terminal pattern rules still
 # apply only if the prerequisite exists.
+unlink('hello.x');
 touch('hello.z');
 
+# subtest 1. test.x is explicitly mentioned.
 run_make_test(q!
 all: hello.z
 %.z:: test.x ; touch $@
 %.x: ;
 !, '', "#MAKE#: Nothing to be done for 'all'.\n");
 
+# subtest 2. hello.x is derived from the stem.
+run_make_test(q!
+all: hello.z
+%.z:: %.x; touch $@
+%.x: ; touch $@
+!, '', "#MAKE#: Nothing to be done for 'all'.\n");
+
 unlink('hello.z');
 
 
diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules
index ded8e0d..81ccadd 100644
--- a/tests/scripts/features/patternrules
+++ b/tests/scripts/features/patternrules
@@ -148,7 +148,8 @@ foo.in:
 'touch foo.in
 touch foo.h
 touch foo.c
-echo foo.c foo.h >foo.o');
+echo foo.c foo.h >foo.o
+rm foo.h');
 
 unlink('foo.in', 'foo.h', 'foo.c', 'foo.o');
 
@@ -232,6 +233,9 @@ all: foo.x foo-mt.x
 
 touch('a.c');
 
+# Even though a.lnk is intermediate, a.lnk is not removed, because it is not
+# created.
+unlink('a.elf', 'a.dbg', 'a.lnk');
 run_make_test(q!
 all: a.elf a.dbg
 
@@ -241,7 +245,33 @@ all: a.elf a.dbg
 !,
     '-j2', ": a.elf a.lnk\n: a.elf a.dbg\n");
 
-unlink('a.c');
+# a.lnk is removed, because it is intermediate.
+unlink('a.elf', 'a.dbg', 'a.lnk');
+run_make_test(q!
+all: a.elf a.dbg
+
+%.elf %.lnk: %.c ; touch $*.elf $*.lnk
+
+%.elf %.dbg: %.lnk ; touch $*.elf $*.dbg
+!,
+    '-j2', "touch a.elf a.lnk\ntouch a.elf a.dbg\nrm a.lnk\n");
+
+unlink('a.elf', 'a.dbg', 'a.lnk');
+
+# a.lnk is not intermediate, because it is explicitly mentioned.
+run_make_test(q!
+all: a.elf a.dbg
+
+%.elf %.lnk: %.c ; touch $*.elf $*.lnk
+
+%.elf %.dbg: %.lnk ; touch $*.elf $*.dbg
+
+install: a.lnk
+.PHONY: install
+!,
+    '-j2', "touch a.elf a.lnk\ntouch a.elf a.dbg\n");
+unlink('a.c', 'a.elf', 'a.dbg', 'a.lnk');
+
 
 # SV 56655: Test patterns matching files containing whitespace
 touch('some file.yy');
@@ -330,7 +360,110 @@ suf:=.z
 unlink('hello.x');
 unlink('test.x');
 
+# Test that chained pattern rules with multiple targets remove all intermediate
+# files.
+# sv 60435.
+
+# subtest 1.
+# a.1 and a.2 are intermediate and should be removed.
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+run_make_test(q!
+a.4:
+%.4: %.1 %.2 ; cat $^ >$@
+%.1 %.2: ; touch $*.1 $*.2
+!, '', "touch a.1 a.2\ncat a.1 a.2 >a.4\nrm a.1 a.2");
+
+# subtest 2.
+# a.1 and a.2 are intermediate and should be removed.
+# a.3 is explicit and should not be removed.
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+run_make_test(q!
+a.4:
+%.4: %.1 %.2 a.3 ; cat $^ >$@
+%.1 %.2: ; touch $*.1 $*.2
+%.3: ; touch $@
+!, '', "touch a.3\ntouch a.1 a.2\ncat a.1 a.2 a.3 >a.4\nrm a.1 a.2");
+
+# subtest 3.
+# a.1 and a.2 are intermediate and should be removed.
+# a.3 is explicit and should not be removed.
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+run_make_test(q!
+a.4:
+%.4: %.1 %.2 a.3 ; cat $^ >$@
+%.1 %.2 %.3: ; touch $*.1 $*.2 $*.3
+!, '', "touch a.1 a.2 a.3\ncat a.1 a.2 a.3 >a.4\nrm a.1 a.2");
+
+# subtest 4.
+# a.1 and a.2 are intermediate and should be removed.
+# a.3 is explicit and should not be removed.
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+run_make_test(q!
+a.4:
+%.4: %.1 %.2 a.3 ; cat $^ >$@
+%.3 %.1 %.2: ; touch $*.1 $*.2 $*.3
+!, '', "touch a.1 a.2 a.3\ncat a.1 a.2 a.3 >a.4\nrm a.1 a.2");
+
+# subtest 5.
+# a.1 and a.2 are intermediate and should be removed.
+# a.3 is explicit and should not be removed.
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+run_make_test(q!
+a.4:
+%.4: a.3 %.1 %.2 ; cat $^ >$@
+%.1 %.2 %.3: ; touch $*.1 $*.2 $*.3
+!, '', "touch a.1 a.2 a.3\ncat a.3 a.1 a.2 >a.4\nrm a.1 a.2");
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+
+# subtest 6.
+# a.2 is intermediate and should be removed.
+# a.1 is mentioned explicitly on an unrelated rule and should not be removed.
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+run_make_test(q!
+a.3:
+%.3: %.1 %.2 ; cat $^ >$@
+%.1 %.2: ; touch $*.1 $*.2
+install: a.1
+.PHONY: install
+!, '', "touch a.1 a.2\ncat a.1 a.2 >a.3\nrm a.2");
+unlink('a.1', 'a.2', 'a.3', 'a.4');
+
+
+# Test removal of intermediate files.
+
+# subtest 1.
+# hello.x is removed, because it is intermediate.
+unlink('hello.x', 'hello.tsk');
+run_make_test(q!
+hello.tsk:
+%.tsk: %.x; touch $@
+%.x: ; touch $@
+!, '', "touch hello.x\ntouch hello.tsk\nrm hello.x");
+
+
+# subtest 2.
+# Even though hello.x is intermediate, it is not removed, because it is not
+# created.
+unlink('hello.tsk');
+touch('hello.x');
+run_make_test(q!
+hello.tsk:
+%.tsk: %.x; touch $@
+%.x: ; touch $@
+!, '', "touch hello.tsk");
+
+# subtest 2.
+# Even though hello.x is intermediate, it is not removed, because it is not
+# created.
+unlink('hello.x', 'hello.tsk');
+run_make_test(q!
+hello.tsk:
+%.tsk: %.x; touch $@
+%.x: ; : $@
+!, '', ": hello.x\ntouch hello.tsk");
+
 
+unlink('hello.x', 'hello.tsk');
 # This tells the test driver that the perl test script executed properly.
 1;
 
