Coder Social home page Coder Social logo

Testing Refactorings about main HOT 1 OPEN

dormaayan avatar dormaayan commented on July 16, 2024
Testing Refactorings

from main.

Comments (1)

yossigil avatar yossigil commented on July 16, 2024

import java.math.BigInteger;
import java.util.*;

import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.function.BiConsumer;

interface Selfie<Self extends Selfie<Self>> {
}

class OO<_1, _2> {
	_1 _1;
	_2 _2;

	public OO(_1 _1, _2 _2) {
		this._1 = _1;
		this._2 = _2;
	}
}

class OI<_1> {
	_1 _1;
	int _2;

	public OI(_1 _1, int _2) {
		this._1 = _1;
		this._2 = _2;
	}
}

class OOs<_1, _2> extends ArrayList<OO<_1, _2>> implements Selfie<OOs<_1, _2>> {
	private static final long serialVersionUID = 1L;
	private List<BiConsumer<_1, _2>> tests = new ArrayList<>();

	public OOs(BiConsumer<_1, _2> f) {
		tests.add(f);

	}

	OOs<_1, _2> against(_1 _1, _2 _2) {
		add(new OO<>(_1, _2));
		return this;
	}

	OOs<_1, _2> and(_1 _1, _2 _2) {
		return against(_1, _2);
	}

	public OOs<_1, _2> go() {
		return this;
	}

	public OOs<_1, _2> to(BiConsumer<A, B> f) {
		return this;
	}
}

class OIs<_1, _2> extends ArrayList<OI<_1>> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	OIs<_1, _2> $(_1 _1, int _2) {
		add(new OI<>(_1, _2));
		return this;
	}

	public OIs<_1, _2> to(BiConsumer<A, B> f, BiConsumer<A, B>... fs) {
		// TODO Auto-generated method stub
		return this;
	}
}

class A {
}

class B {
}

class Main {
	public static void testFib(Integer n, BigInteger b) {
		assert fib(n).equals(b);
	}

	public static BigInteger fib(Integer n) {
		if (n == null)
			return BigInteger.ZERO;
		return fib1(n.intValue());
	}

	public static BigInteger sqrt(Integer n) {
		if (n == null)
			return BigInteger.ZERO;
		return fib1(n.intValue());
	}

	public static BigInteger fib1(int n) {
		if (n <= 1)
			return BigInteger.ZERO;
		else
			return fib1(n - 1).add(fib1(n - 2));
	}

	static int inc(int a) {
		return a + 1;
	}

	public static void main(String[] args) {
		Tuples.to(Main::testFib).against(12, BigInteger.ZERO).and(3, BigInteger.valueOf(3))
				.and(4, BigInteger.valueOf(4)).go();
		Tuples.to(Main::inc).of(0, 1).of(1, 2).of(1, 2);
	}

	static void f(A a, B b) {
	}

	static void g(A a, B b) {
	};

	static B h(A a) {
		return null;
	};
}

class Tuples {
	static <A, B> OOs<A, B> to(BiConsumer<A, B> f) {
		return new OOs<A, B>(f);
	}

	static <A> Os<A> to2(Consumer<A> f) {
		return new Os<A>();
	}

	static IIs to(IntFunction f) {
		return new IIs(f);
	}

}

class IIs {

	private IntFunction f;

	public IIs(IntFunction f) {
		this.f = f;
	}

	public IIs of(int a, int b) {
		return this;
	}

}

class Os<O> {
}

class MapTest {
	static {
		Tuples.to2(MapTest::MapTest);
	}

	private Map<String, String> map;

	MapTest(Map<String, String> map) {
		this.map = map;
	}
}
`

from main.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.