A nonvolatile semiconductor memory device has a special test mode and circuitry
for counting its own fail bits. During the test mode, test data is stored in the
memory, and also in a special expected data buffer. The test data stored in the
memory cells are then compared to that stored in the expected data buffer. Where
there is no correspondence, fail bits are detected. The lack of correspondence
is registered, counted, and output to a data output buffer block.