author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Wed, 23 Oct 2013 14:56:31 +0200 | |
changeset 1388 | d28e1c58f508 |
parent 1298 | b19da82653ff |
parent 1352 | 7bc78045adfd |
permissions | -rw-r--r-- |
Martin@1352 | 1 |
/** |
Martin@1352 | 2 |
* Back 2 Browser Bytecode Translator |
Martin@1352 | 3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Martin@1352 | 4 |
* |
Martin@1352 | 5 |
* This program is free software: you can redistribute it and/or modify |
Martin@1352 | 6 |
* it under the terms of the GNU General Public License as published by |
Martin@1352 | 7 |
* the Free Software Foundation, version 2 of the License. |
Martin@1352 | 8 |
* |
Martin@1352 | 9 |
* This program is distributed in the hope that it will be useful, |
Martin@1352 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
Martin@1352 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Martin@1352 | 12 |
* GNU General Public License for more details. |
Martin@1352 | 13 |
* |
Martin@1352 | 14 |
* You should have received a copy of the GNU General Public License |
Martin@1352 | 15 |
* along with this program. Look for COPYING file in the top folder. |
Martin@1352 | 16 |
* If not, see http://opensource.org/licenses/GPL-2.0. |
Martin@1352 | 17 |
*/ |
jaroslav@1294 | 18 |
package org.apidesign.bck2brwsr.tck; |
jaroslav@1294 | 19 |
|
jaroslav@1294 | 20 |
import java.util.EnumMap; |
jaroslav@1294 | 21 |
import java.util.EnumSet; |
jaroslav@1294 | 22 |
import org.apidesign.bck2brwsr.vmtest.Compare; |
jaroslav@1294 | 23 |
import org.apidesign.bck2brwsr.vmtest.VMTest; |
jaroslav@1294 | 24 |
import org.testng.annotations.Factory; |
jaroslav@1294 | 25 |
|
jaroslav@1294 | 26 |
/** |
jaroslav@1294 | 27 |
* |
jaroslav@1294 | 28 |
* @author Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jaroslav@1294 | 29 |
*/ |
jaroslav@1294 | 30 |
public class EnumsTest { |
jaroslav@1294 | 31 |
enum Color { |
jaroslav@1294 | 32 |
B, W; |
jaroslav@1294 | 33 |
} |
jaroslav@1294 | 34 |
|
jaroslav@1294 | 35 |
@Compare public String enumSet() { |
jaroslav@1294 | 36 |
try { throw new Exception(); } catch (Exception ex) {} |
jaroslav@1294 | 37 |
EnumSet<Color> c = EnumSet.allOf(Color.class); |
jaroslav@1294 | 38 |
return c.toString(); |
jaroslav@1294 | 39 |
} |
jaroslav@1294 | 40 |
|
jaroslav@1294 | 41 |
@Compare public String enumSetOneByOne() { |
jaroslav@1294 | 42 |
EnumSet<Color> c = EnumSet.of(Color.B, Color.W); |
jaroslav@1294 | 43 |
return c.toString(); |
jaroslav@1294 | 44 |
} |
jaroslav@1294 | 45 |
|
jaroslav@1294 | 46 |
@Compare public boolean enumFirstContains() { |
jaroslav@1294 | 47 |
EnumSet<Color> c = EnumSet.of(Color.B); |
jaroslav@1294 | 48 |
return c.contains(Color.B); |
jaroslav@1294 | 49 |
} |
jaroslav@1294 | 50 |
|
jaroslav@1294 | 51 |
@Compare public boolean enumFirstDoesNotContains() { |
jaroslav@1294 | 52 |
EnumSet<Color> c = EnumSet.of(Color.B); |
jaroslav@1294 | 53 |
return c.contains(Color.W); |
jaroslav@1294 | 54 |
} |
jaroslav@1294 | 55 |
|
jaroslav@1294 | 56 |
@Compare public boolean enumSndContains() { |
jaroslav@1294 | 57 |
EnumSet<Color> c = EnumSet.of(Color.W); |
jaroslav@1294 | 58 |
return c.contains(Color.W); |
jaroslav@1294 | 59 |
} |
jaroslav@1294 | 60 |
|
jaroslav@1294 | 61 |
@Compare public boolean enumSecondDoesNotContains() { |
jaroslav@1294 | 62 |
EnumSet<Color> c = EnumSet.of(Color.W); |
jaroslav@1294 | 63 |
return c.contains(Color.B); |
jaroslav@1294 | 64 |
} |
jaroslav@1294 | 65 |
|
jaroslav@1294 | 66 |
@Compare public String enumMap() { |
jaroslav@1294 | 67 |
EnumMap<Color,String> c = new EnumMap(Color.class); |
jaroslav@1294 | 68 |
c.put(Color.B, "Black"); |
jaroslav@1294 | 69 |
c.put(Color.W, "White"); |
jaroslav@1294 | 70 |
return c.toString(); |
jaroslav@1294 | 71 |
} |
jaroslav@1294 | 72 |
|
jaroslav@1294 | 73 |
@Factory public static Object[] create() { |
jaroslav@1294 | 74 |
return VMTest.create(EnumsTest.class); |
jaroslav@1294 | 75 |
} |
jaroslav@1294 | 76 |
} |