1 //: The goal of layers is to make programs more easy to understand and more 2 //: malleable, easy to rewrite in radical ways without accidentally breaking 3 //: some corner case. Tests further both goals. They help understandability by 4 //: letting one make small changes and get feedback. What if I wrote this line 5 //: like so? What if I removed this function call, is it really necessary? 6 //: Just try it, see if the tests pass. Want to explore rewriting this bit in 7 //: this way? Tests put many refactorings on a firmer footing. 8 //: 9 //: But the usual way we write tests seems incomplete. Refactorings tend to 10 //: work in the small, but don't help with changes to function boundaries. If 11 //: you want to extract a new function you have to manually test-drive it to 12 //: create tests for it. If you want to inline a function its tests are no 13 //: longer valid. In both cases you end up having to reorganize code as well as 14 //: tests, an error-prone activity. 15 //: 16 //: In response, this layer introduces the notion of *domain-driven* testing. 17 //: We focus on the domain of inputs the whole program needs to handle rather 18 //: than the correctness of individual functions. All tests invoke the program 19 //: in a single way: by calling run() with some input. As the program operates 20 //: on the input, it traces out a list of _facts_ deduced about the domain: 21 //: trace("label") << "fact 1: " << val; 22 //: 23 //# dwm - dynamic window manager # © 2006-2007 Anselm R. Garbe, Sander van Dijk include config.mk SRC = dwm.c OBJ = ${SRC:.c=.o} all: options dwm options: @echo dwm build options: @echo "CFLAGS = ${CFLAGS}" @echo "LDFLAGS = ${LDFLAGS}" @echo "CC = ${CC}" .c.o: @echo CC $< @${CC} -c ${CFLAGS} $< ${OBJ}: config.h config.mk config.h: @echo creating $@ from config.def.h @cp config.def.h $@ dwm: ${OBJ} @echo CC -o $@ @${CC} -o $@ ${OBJ} ${LDFLAGS} clean: @echo cleaning @rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz dist: clean @echo creating dist tarball @mkdir -p dwm-${VERSION} @cp -R LICENSE Makefile README config.def.h config.mk \ dwm.1 ${SRC} dwm-${VERSION} @tar -cf dwm-${VERSION}.tar dwm-${VERSION} @gzip dwm-${VERSION}.tar @rm -rf dwm-${VERSION} install: all @echo installing executable file to ${DESTDIR}${PREFIX}/bin @mkdir -p ${DESTDIR}${PREFIX}/bin @cp -f dwm ${DESTDIR}${PREFIX}/bin @chmod 755 ${DESTDIR}${PREFIX}/bin/dwm @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 @mkdir -p ${DESTDIR}${MANPREFIX}/man1 @sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 uninstall: @echo removing executable file from ${DESTDIR}${PREFIX}/bin @rm -f ${DESTDIR}${PREFIX}/bin/dwm @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 @rm -f ${DESTDIR}${MANPREFIX}/man1/dwm.1 .PHONY: all options clean dist install uninstall