Program: 4482
Project: 4482
Buggy source:
@Test public void testSpatialPoolerPrimerDelay(){
  Parameters p=NetworkTestHarness.getParameters().copy();
  p.setParameterByKey(KEY.RANDOM,new MersenneTwister(42));
  int[][] inputs=new int[7][8];
  inputs[0]=new int[]{1,1,0,0,0,0,0,1};
  inputs[1]=new int[]{1,1,1,0,0,0,0,0};
  inputs[2]=new int[]{0,1,1,1,0,0,0,0};
  inputs[3]=new int[]{0,0,1,1,1,0,0,0};
  inputs[4]=new int[]{0,0,0,1,1,1,0,0};
  inputs[5]=new int[]{0,0,0,0,1,1,1,0};
  inputs[6]=new int[]{0,0,0,0,0,1,1,1};
  final int[] expected0=new int[]{0,1,0,0,0,1,0,1,0,0,0,1,1,0,0,0,1,0,0,0};
  final int[] expected1=new int[]{0,1,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0};
  Layer<int[]> l=new PALayer<>(p,null,new PASpatialPooler(),null,null,null);
  l.subscribe(new Observer<Inference>(){
    int test=0;
    @Override public void onCompleted(){
    }
    @Override public void onError(    Throwable e){
      e.printStackTrace();
    }
    @Override public void onNext(    Inference i){
      if (test == 0) {
        assertTrue(Arrays.equals(expected0,i.getSDR()));
      }
      if (test == 1) {
        assertTrue(Arrays.equals(expected1,i.getSDR()));
      }
      ++test;
    }
  }
);
  l.compute(inputs[0]);
  l.compute(inputs[1]);
  p.setParameterByKey(KEY.RANDOM,new MersenneTwister(42));
  p.setParameterByKey(KEY.SP_PRIMER_DELAY,1);
  Layer<int[]> l2=new PALayer<>(p,null,new PASpatialPooler(),null,null,null);
  l2.subscribe(new Observer<Inference>(){
    @Override public void onCompleted(){
    }
    @Override public void onError(    Throwable e){
      e.printStackTrace();
    }
    @Override public void onNext(    Inference i){
      assertTrue(Arrays.equals(expected1,i.getSDR()));
    }
  }
);
  l2.compute(inputs[0]);
  l2.compute(inputs[1]);
}

Fixed version (ground truth):
@Test public void testSpatialPoolerPrimerDelay(){
  Parameters p=NetworkTestHarness.getParameters().copy();
  p.setParameterByKey(KEY.RANDOM,new MersenneTwister(42));
  int[][] inputs=new int[7][8];
  inputs[0]=new int[]{1,1,0,0,0,0,0,1};
  inputs[1]=new int[]{1,1,1,0,0,0,0,0};
  inputs[2]=new int[]{0,1,1,1,0,0,0,0};
  inputs[3]=new int[]{0,0,1,1,1,0,0,0};
  inputs[4]=new int[]{0,0,0,1,1,1,0,0};
  inputs[5]=new int[]{0,0,0,0,1,1,1,0};
  inputs[6]=new int[]{0,0,0,0,0,1,1,1};
  final int[] expected0=new int[]{0,1,0,0,0,1,0,1,0,0,0,1,1,0,0,0,1,0,0,0};
  final int[] expected1=new int[]{0,1,0,0,0,1,0,0,0,0,0,1,1,1,0,0,1,0,0,0};
  Layer<int[]> l=new PALayer<>(p,null,new PASpatialPooler(),null,null,null);
  l.subscribe(new Observer<Inference>(){
    int test=0;
    @Override public void onCompleted(){
    }
    @Override public void onError(    Throwable e){
      e.printStackTrace();
    }
    @Override public void onNext(    Inference i){
      if (test == 0) {
        assertTrue(Arrays.equals(expected0,i.getSDR()));
      }
      if (test == 1) {
        assertTrue(Arrays.equals(expected1,i.getSDR()));
      }
      ++test;
    }
  }
);
  l.compute(inputs[0]);
  l.compute(inputs[1]);
  p.setParameterByKey(KEY.RANDOM,new MersenneTwister(42));
  p.setParameterByKey(KEY.SP_PRIMER_DELAY,1);
  Layer<int[]> l2=new PALayer<>(p,null,new PASpatialPooler(),null,null,null);
  l2.subscribe(new Observer<Inference>(){
    @Override public void onCompleted(){
    }
    @Override public void onError(    Throwable e){
      e.printStackTrace();
    }
    @Override public void onNext(    Inference i){
      assertTrue(Arrays.equals(expected1,i.getSDR()));
    }
  }
);
  l2.compute(inputs[0]);
  l2.compute(inputs[1]);
}