/****************************************************************
*								*
*	Copyright 2013 Fidelity Information Services, Inc	*
*								*
*	This source code contains the intellectual property	*
*	of its copyright holder(s), and is made available	*
*	under a license.  If you do not know the terms of	*
*	the license, please stop and do not read further.	*
*								*
****************************************************************/
package com.test.ji;

import java.util.HashSet;

/**
 * A set of (though currently only one) functions that have to do with generation of M-related constructs.
 */
public class M {
	private static HashSet<String> mVarNames = new HashSet<String>();

	public static String genVarName(boolean global) {
		StringBuilder builder = new StringBuilder();

		do {
			int length = 3 + (int)(Math.random() * 7);
			builder = new StringBuilder(length);

			if (global)
				builder.append("^");

			for (int i = 0; i < length; i++)
				builder.append((char)(97 + (int)(Math.random() * 26)));
		} while (mVarNames.contains(builder.toString()));

		return builder.toString();
	}
}

@@ -71,17 +71,17 @@
 %09%09%09%09%09*%0A*
-%09
+ 
 Copyrigh
@@ -122,16 +122,119 @@
 es, Inc%09
+%09*%0A*%09%09%09%09%09%09%09%09*%0A* Copyright (c) 2018 YottaDB LLC. and/or its subsidiaries.%09*%0A* All rights reserved.%09%09%09%09%09%09
 *%0A*%09%09%09%09%09
@@ -1015,16 +1015,369 @@
 d(%22%5E%22);%0A
+%09%09%09/* We have had test failures where the generated M variable name matches a java keyword%0A%09%09%09 * (e.g. %22try%22, %22null%22 which are disallowed as variables in java code).%0A%09%09%09 * To avoid such issues, we prefix a %22z%22 to all variable names (which still keeps it a valid M name).%0A%09%09%09 * This assumes no java keyword begins with %22z%22.%0A%09%09%09 */%0A%09%09%09builder.append(%22z%22);
 %0A%09%09%09for 

Fix occasional java/callins subtest failure due to random M variable names matching java keywords (#355)