X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Ftest%2FJalviewJSTest.java;h=5ab18ca38f373df82e0673ddd63e682fc33630fc;hb=f9f73d5a467d8049cd14e799f136fb7af063d9f0;hp=a2026a8aec8c5ec036e0817e0f57f32d5e15277d;hpb=cbd5753d121698582e3f87a4e2b4ad41f25b5c1c;p=jalview.git diff --git a/utils/test/JalviewJSTest.java b/utils/test/JalviewJSTest.java index a2026a8..5ab18ca 100644 --- a/utils/test/JalviewJSTest.java +++ b/utils/test/JalviewJSTest.java @@ -1,4 +1,27 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package test; +import jalview.gui.JvOptionPane; +import jalview.util.JSONUtils; + import java.awt.BorderLayout; import java.awt.ComponentOrientation; import java.awt.Container; @@ -9,6 +32,7 @@ import java.awt.MediaTracker; import java.io.File; import java.text.DecimalFormat; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.swing.ImageIcon; @@ -26,6 +50,8 @@ import javax.swing.SwingConstants; import javax.swing.WindowConstants; import javax.swing.border.TitledBorder; +import org.json.simple.parser.ParseException; + /** * A class with a main method entry point for ad hoc tests of JalviewJS * behaviour. The J2S transpiler should generate an html entry point for this @@ -35,9 +61,77 @@ public class JalviewJSTest extends JPanel { public static void main(String[] args) { - new JalviewJSTest().doTest2(); + new JalviewJSTest().doTest6(); + } + + void doTest6() + { + /* + * check for transpiler fix associated with JSONParser yylex.java use of charAt() + * instead of codePointAt(); moved here from PDBFTSRestClient + */ + + String s = "e"; + char c = 'c'; + char f = 'f'; + s += c | f; + int x = c & f; + int y = 2 & c; + int z = c ^ 5; + String result = s + x + y + z; + System.out.println("Expected " + "e103982102, found " + result); + try + { + Map jsonObj = (Map) JSONUtils + .parse("{\"a\":3}"); + System.out.println(jsonObj); + } catch (ParseException e) + { + e.printStackTrace(); + } } + /** + * Dialog message truncation + */ + void doTest5() + { + JFrame main = new JFrame(); + main.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + main.setContentPane(new JPanel()); + main.setMinimumSize(new Dimension(100, 100)); + main.pack(); + main.setVisible(true); + + /* + * like AlignFrame.delete_actionPerformed() + * except here it works fine, also in JS + */ + JvOptionPane dialog = JvOptionPane.newOptionDialog(null); + Object[] options = new Object[] { "OK", "Cancel" }; + String msg = "Deleting all sequences will close the alignment window.
Confirm deletion or Cancel."; + dialog.showDialog(msg, "", JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, options[0]); + + } + + void doTest4() + { + Float fl = new Float(0f); + System.out.println(fl.isInfinite()); + System.out.println(fl.isNaN()); + + System.out.println(Float.isInfinite(0f)); + System.out.println(Float.isFinite(0f)); + System.out.println(Float.isNaN(0f)); + } + + void doTest3() + { + System.out.println("Mungo".toLowerCase(Locale.getDefault())); + System.out.println("Mungo".toLowerCase(Locale.ENGLISH)); + System.out.println("Mungo".toLowerCase(Locale.ROOT)); + } + void doTest2() { Map map = new HashMap<>(); File f1 = new File("/var/folders/y/xyz"); @@ -48,10 +142,11 @@ public class JalviewJSTest extends JPanel System.out.println("f2 hashCode = " + f2.hashCode()); System.out.println(map.get(f2)); } + /** * Put some content in a JFrame and show it */ - void doTest() + void doTest1() { System.out.println("ab;c;".split(";")); new DecimalFormat("###,###").format((Integer) 1); @@ -212,10 +307,12 @@ private ImageIcon getImage(String name) { ImageIcon icon = new ImageIcon(getClass().getResource(name)); while(icon.getImageLoadStatus() == MediaTracker.LOADING) - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } + { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + } + } return icon; } }