looklook 0.9.0

Descriptive signal synthesiser.
// Copyright 2026 Gabriel Bjørnager Jensen.
//
// This file is part of LOOKLOOK.
//
// LOOKLOOK is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later ver-
// sion.
//
// LOOKLOOK is distributed in the hope that it will be useful, but WITHOUT ANY WAR-
// RANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along
// with LOOKLOOK. If not, see <https://www.gnu.org/licenses/>.

//! Tests for [`Regs`].

#![cfg(test)]

use crate::vm::Regs;

#[test]
fn test_regs_inc_pc() {
	let mut regs = Regs::default();

	assert_eq!(regs.pc().as_u32(), 0);

	regs.inc_pc(1);
	assert_eq!(regs.pc().as_u32(), 1);

	regs.inc_pc(2);
	assert_eq!(regs.pc().as_u32(), 3);

	regs.inc_pc(4);
	assert_eq!(regs.pc().as_u32(), 7);

	regs.inc_pc(8);
	assert_eq!(regs.pc().as_u32(), 15);

	regs.inc_pc(16);
	assert_eq!(regs.pc().as_u32(), 31);

	regs.inc_pc(32);
	assert_eq!(regs.pc().as_u32(), 63);

	regs.inc_pc(64);
	assert_eq!(regs.pc().as_u32(), 127);

	regs.inc_pc(128);
	assert_eq!(regs.pc().as_u32(), 255);

	regs.inc_pc(256);
	assert_eq!(regs.pc().as_u32(), 511);

	regs.inc_pc(512);
	assert_eq!(regs.pc().as_u32(), 1023);

	regs.inc_pc(1024);
	assert_eq!(regs.pc().as_u32(), 2047);

	regs.inc_pc(2048);
	assert_eq!(regs.pc().as_u32(), 4095);

	regs.inc_pc(4096);
	assert_eq!(regs.pc().as_u32(), 8191);

	regs.inc_pc(8192);
	assert_eq!(regs.pc().as_u32(), 16383);

	regs.inc_pc(16384);
	assert_eq!(regs.pc().as_u32(), 32767);

	regs.inc_pc(32768);
	assert_eq!(regs.pc().as_u32(), 65535);

	regs.inc_pc(65536);
	assert_eq!(regs.pc().as_u32(), 131071);

	regs.inc_pc(131072);
	assert_eq!(regs.pc().as_u32(), 262143);

	regs.inc_pc(262144);
	assert_eq!(regs.pc().as_u32(), 524287);

	regs.inc_pc(524288);
	assert_eq!(regs.pc().as_u32(), 1048575);

	regs.inc_pc(1048576);
	assert_eq!(regs.pc().as_u32(), 2097151);

	regs.inc_pc(2097152);
	assert_eq!(regs.pc().as_u32(), 4194303);

	regs.inc_pc(4194304);
	assert_eq!(regs.pc().as_u32(), 8388607);

	regs.inc_pc(8388608);
	assert_eq!(regs.pc().as_u32(), 16777215);

	regs.inc_pc(16777216);
	assert_eq!(regs.pc().as_u32(), 33554431);

	regs.inc_pc(33554432);
	assert_eq!(regs.pc().as_u32(), 67108863);
}