A permutation test for matching and its asymptotic distribution