/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Yegor Bugayenko
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.cactoos.scalar;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.cactoos.Proc;
import org.cactoos.Scalar;
import org.cactoos.iterable.IterableOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
 * Test case for {@link Or}.
 *
 * @author Vseslav Sekorin (vssekorin@gmail.com)
 * @version $Id$
 * @since 0.8
 * @checkstyle JavadocMethodCheck (500 lines)
 * @checkstyle MagicNumber (500 line)
 */
public final class OrTest {

    @Test
    public void allFalse() throws Exception {
        MatcherAssert.assertThat(
            new Or(
                new False(),
                new False(),
                new False(),
                new False(),
                new False()
            ).value(),
            Matchers.equalTo(false)
        );
    }

    @Test
    public void oneTrue() throws Exception {
        MatcherAssert.assertThat(
            new Or(
                new False(),
                new True(),
                new False(),
                new False(),
                new False()
            ).value(),
            Matchers.equalTo(true)
        );
    }

    @Test
    public void allTrue() throws Exception {
        MatcherAssert.assertThat(
            new Or(
                new IterableOf<Scalar<Boolean>>(
                    new True(),
                    new True(),
                    new True(),
                    new True(),
                    new True()
                )
            ).value(),
            Matchers.equalTo(true)
        );
    }

    @Test
    public void emptyIterator() throws Exception {
        MatcherAssert.assertThat(
            new Or(Collections.emptyList()).value(),
            Matchers.equalTo(false)
        );
    }

    @Test
    public void testProc() throws Exception {
        final List<Integer> list = new LinkedList<>();
        new Or(
            new IterableOf<>(1, 2, 3, 4),
            (Proc<Integer>) list::add
        ).value();
        MatcherAssert.assertThat(
            list.size(),
            Matchers.equalTo(4)
        );
    }

    @Test
    public void testFunc() throws Exception {
        MatcherAssert.assertThat(
            new Or(
                new IterableOf<>(-1, 1, 0),
                input -> input > 0
            ).value(),
            Matchers.equalTo(true)
        );
    }
}

@@ -1273,20 +1273,22 @@
 cactoos.
-Proc
+Scalar
 ;%0Aimport
@@ -1298,32 +1298,40 @@
 g.cactoos.Scalar
+HasValue
 ;%0Aimport org.cac
@@ -1940,32 +1940,24 @@
             
-).value(
 ),%0A         
@@ -1959,32 +1959,36 @@
         
-Matchers.equalTo
+new ScalarHasValue%3C%3E
 (false)%0A
@@ -2265,32 +2265,24 @@
             
-).value(
 ),%0A         
@@ -2284,32 +2284,36 @@
         
-Matchers.equalTo
+new ScalarHasValue%3C%3E
 (true)%0A 
@@ -2672,32 +2672,24 @@
             
-).value(
 ),%0A         
@@ -2691,32 +2691,36 @@
         
-Matchers.equalTo
+new ScalarHasValue%3C%3E
 (true)%0A 
@@ -2874,24 +2874,16 @@
 yList())
-.value()
 ,%0A      
@@ -2888,32 +2888,36 @@
         
-Matchers.equalTo
+new ScalarHasValue%3C%3E
 (false)%0A
@@ -3119,33 +3119,37 @@
     
-(Proc%3CInteger%3E)
+input -%3E %7B
  list
-::
+.
 add
+(input); %7D
 %0A   
@@ -3307,222 +3307,795 @@
 test
-Func() throws Exception %7B%0A        MatcherAssert.assertThat(%0A            new Or(%0A                new IterableOf%3C%3E(-1, 1, 0),%0A                input -%3E input %3E 0%0A            ).value(),%0A            Matchers.equalTo(tru
+ProcVarargs() throws Exception %7B%0A        final List%3CInteger%3E list = new LinkedList%3C%3E();%0A        new Or(%0A            input -%3E %7B list.add(input); %7D,%0A            2, 3, 4%0A        ).value();%0A        MatcherAssert.assertThat(%0A            list.size(),%0A            Matchers.equalTo(3)%0A        );%0A    %7D%0A%0A    @Test%0A    public void testFunc() throws Exception %7B%0A        MatcherAssert.assertThat(%0A            new Or(%0A                new IterableOf%3C%3E(-1, 1, 0),%0A                input -%3E input %3E 0%0A            ),%0A            new ScalarHasValue%3C%3E(true)%0A        );%0A    %7D%0A%0A    @Test%0A    public void testFuncVarargs() throws Exception %7B%0A        MatcherAssert.assertThat(%0A            new Or(%0A                input -%3E input %3E 0,%0A                -1, -2, 0%0A            ),%0A            new ScalarHasValue%3C%3E(fals
 e)%0A 

Add tests