author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Fri, 05 Apr 2013 12:43:17 +0200 | |
branch | model |
changeset 934 | 19b4ddc302a6 |
child 960 | 4887e22cb810 |
permissions | -rw-r--r-- |
jaroslav@934 | 1 |
/** |
jaroslav@934 | 2 |
* Back 2 Browser Bytecode Translator |
jaroslav@934 | 3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jaroslav@934 | 4 |
* |
jaroslav@934 | 5 |
* This program is free software: you can redistribute it and/or modify |
jaroslav@934 | 6 |
* it under the terms of the GNU General Public License as published by |
jaroslav@934 | 7 |
* the Free Software Foundation, version 2 of the License. |
jaroslav@934 | 8 |
* |
jaroslav@934 | 9 |
* This program is distributed in the hope that it will be useful, |
jaroslav@934 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jaroslav@934 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jaroslav@934 | 12 |
* GNU General Public License for more details. |
jaroslav@934 | 13 |
* |
jaroslav@934 | 14 |
* You should have received a copy of the GNU General Public License |
jaroslav@934 | 15 |
* along with this program. Look for COPYING file in the top folder. |
jaroslav@934 | 16 |
* If not, see http://opensource.org/licenses/GPL-2.0. |
jaroslav@934 | 17 |
*/ |
jaroslav@934 | 18 |
package org.apidesign.bck2brwsr.htmlpage; |
jaroslav@934 | 19 |
|
jaroslav@934 | 20 |
import org.apidesign.bck2brwsr.core.JavaScriptBody; |
jaroslav@934 | 21 |
import org.apidesign.bck2brwsr.vmtest.BrwsrTest; |
jaroslav@934 | 22 |
import org.apidesign.bck2brwsr.vmtest.VMTest; |
jaroslav@934 | 23 |
import org.testng.annotations.Factory; |
jaroslav@934 | 24 |
|
jaroslav@934 | 25 |
/** |
jaroslav@934 | 26 |
* |
jaroslav@934 | 27 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jaroslav@934 | 28 |
*/ |
jaroslav@934 | 29 |
public class ConvertTypesTest { |
jaroslav@934 | 30 |
@JavaScriptBody(args = { }, body = "var json = new Object();" |
jaroslav@934 | 31 |
+ "json.firstName = 'son';\n" |
jaroslav@934 | 32 |
+ "json.lastName = 'dj';\n" |
jaroslav@934 | 33 |
+ "json.sex = 'MALE';\n" |
jaroslav@934 | 34 |
+ "return json;" |
jaroslav@934 | 35 |
) |
jaroslav@934 | 36 |
private static native Object createJSON(); |
jaroslav@934 | 37 |
|
jaroslav@934 | 38 |
@BrwsrTest |
jaroslav@934 | 39 |
public void testConvertToPeople() { |
jaroslav@934 | 40 |
final Object o = createJSON(); |
jaroslav@934 | 41 |
|
jaroslav@934 | 42 |
Person p = new Person(o); |
jaroslav@934 | 43 |
|
jaroslav@934 | 44 |
assert "son".equals(p.getFirstName()) : "First name: " + p.getFirstName(); |
jaroslav@934 | 45 |
assert "dj".equals(p.getLastName()) : "Last name: " + p.getLastName(); |
jaroslav@934 | 46 |
// assert Sex.MALE.equals(p.getSex()) : "Sex: " + p.getSex(); |
jaroslav@934 | 47 |
} |
jaroslav@934 | 48 |
|
jaroslav@934 | 49 |
@Factory public static Object[] create() { |
jaroslav@934 | 50 |
return VMTest.create(ConvertTypesTest.class); |
jaroslav@934 | 51 |
} |
jaroslav@934 | 52 |
} |