Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368905 - Eunit Javascript test regression in lang.expression package
Summary: Eunit Javascript test regression in lang.expression package
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Paul Harmon CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-18 00:10 EST by Huang Ji Yong CLA
Modified: 2017-02-23 14:18 EST (History)
3 users (show)

See Also:


Attachments
Patch to resolve the defect (1.65 KB, patch)
2012-01-18 07:43 EST, Huang Ji Yong CLA
lasher: iplog+
Details | Diff
patch for comment 2 (1.02 KB, patch)
2012-02-17 04:28 EST, Huang Ji Yong CLA
lasher: iplog+
Details | Diff
EUnit test results (2.37 KB, application/octet-stream)
2012-02-21 15:43 EST, Matt Heitz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Huang Ji Yong CLA 2012-01-18 00:10:01 EST
The 2 variations is successful in 0.7 but fail in 0.8I1
lang.expression.initializer.ObjectInitialization001
	function recordToAnyAssignment01() {@Test}
		firstRec myLittleRecord;
		any1 any = firstRec;
		any2 any = any1;
		any1.thing2 = "modified.two";
		expected string = "two";
		LogResult.assertStringEqual1(expected, firstRec.thing2);
	end


lang.expression.parameter.NumberParameter003
/*
NumberParameters003::testFunctionParameterInOutWithUpdate: ERROR - uncaught exception for: NumberParameters003::testFunctionParameterInOutWithUpdate
    => CRRUI2017E: [CRRUI2017E] The value "eglx.lang.anyboxedobject" of type eglx.lang.anyboxedobject cannot be converted to type smallint
NumberParameters003::testFunctionParameterOutWithUpdate: ERROR - uncaught exception for: NumberParameters003::testFunctionParameterOutWithUpdate
    => CRRUI2017E: [CRRUI2017E] The value "eglx.lang.anyboxedobject" of type eglx.lang.anyboxedobject cannot be converted to type smallint
*/
	
     function testFunctionParameterInOutWithUpdate() {@Test}
    	localAny any = 3;
    	updateInOutParameter(localAny);
      	LogResult.assertTrue1((localAny as smallInt) == updated);
    end	
    
    function testFunctionParameterOutWithUpdate() {@Test}
    	localAny any = 3;
	 	updateOutParameter(localAny);
	 	LogResult.assertTrue1((localAny as smallInt) == updated);
//	 	LogResult.failed("Java COMPILE value-to-reference");
    end
Comment 1 Huang Ji Yong CLA 2012-01-18 07:43:30 EST
Created attachment 209674 [details]
Patch to resolve the defect

This problem is caused by IR change. The RHS of assignment to an any type is changed from BoxedExpression to AsExpression.
The attached fix can resolve this problem but when testing EUnit, it causes some failure in JSONLib. I will investigate later.
Comment 2 Paul Harmon CLA 2012-01-24 10:20:50 EST
I have put a temporary change in IRUtils to fix this problem. The difference in the IRs that is causing the problem for JS gen is that the boxing expression was being wrappered in an AS expression. In .7, we only created a boxing expression when making any type compatible with ANY.

The change I made was to skip creating the AS expression, if the type being converted to is ANY.

NOTE: There is still a problem in JS generation. If I code the following:

		firstRec myLittleRecord;  //any record definition will do
		any1 any?;
		any1 = firstRec;
		any1 = firstrec as any;


The first assignment statement will now (after my fix) result in the record being cloned before assinging to the any1. However, the second assignment does NOT do a clone.

JSGen needs to be changed to tolerate the AS expression. Once JSGen is fixed, we can remove the change I made to IRUtils for I1.
Comment 3 Matt Heitz CLA 2012-01-24 16:46:55 EST
After Paul's change, one small change was needed in the runtime.  In edt_runtime.js I made EAny.fromEAny know how to convert an AnyBoxedObject into an Any.

I'm changing the target of this bug from I1 to I2 because the regressions are now fixed, but the problem described by Paul needs to be fixed too.
Comment 4 Huang Ji Yong CLA 2012-02-17 04:28:43 EST
Created attachment 211164 [details]
patch for comment 2

Hi Paul,
Please continue your change described in comment 2.
Thanks.
Comment 5 Matt Heitz CLA 2012-02-21 15:43:37 EST
Created attachment 211364 [details]
EUnit test results
Comment 6 Matt Heitz CLA 2012-02-21 15:57:25 EST
I ran the failing variations with the current EDT 0.8 I2 build and EDT 0.7.  The results are exactly the same!  They're in the attached zip file if you want to see them.

In 0.7 and 0.8 I2, the variation lang.expression.initializer.ObjectInitialization001.recordToAnyAssignment01 does not fail.  But there are many failures in both 0.7 and 0.8 I2 when you run lang.expression.parameter.NumberParameter003.  All of those failures happen when an Any variable is passed to a function whose parameter is a Number.

Paul and Ji Yong, please discuss what changes need to be made.
Comment 7 Huang Ji Yong CLA 2012-02-22 00:06:59 EST
(In reply to comment #6)
> I ran the failing variations with the current EDT 0.8 I2 build and EDT 0.7. 
> The results are exactly the same!  They're in the attached zip file if you want
> to see them.
> 
> In 0.7 and 0.8 I2, the variation
> lang.expression.initializer.ObjectInitialization001.recordToAnyAssignment01
> does not fail.  But there are many failures in both 0.7 and 0.8 I2 when you run
> lang.expression.parameter.NumberParameter003.  All of those failures happen
> when an Any variable is passed to a function whose parameter is a Number.
> 
> Paul and Ji Yong, please discuss what changes need to be made.

Matt,
Yes, the regression are resolved now. But in comment 2, Paul states "we can remove the change I made to IRUtils for I1." So I transfer this bug to Paul for additional work.

While the failure in lang.expression.parameter.NumberParameter003, it is not regression. I wonder if we should open another bug for it. We have a lot of failures in EUnit. In the past, only regressions are opened as bugs.
Comment 8 Paul Harmon CLA 2012-02-22 09:10:21 EST
Are you saying that I should remove the "patch" I put in for I1? Does JSGen now generate a clone when using an explicit AS expression on the assingment?
Comment 9 Huang Ji Yong CLA 2012-02-22 09:15:40 EST
(In reply to comment #8)
> Are you saying that I should remove the "patch" I put in for I1? Does JSGen now
> generate a clone when using an explicit AS expression on the assingment?

Yes. Clone is generated for As expression of record.
Please go ahead to remove the "patch".
Comment 10 Paul Harmon CLA 2012-02-22 10:52:41 EST
I have removed the patch that was put in for I1.
Comment 11 Huang Ji Yong CLA 2012-02-29 02:26:17 EST
Verified in build 0.8.0.v201202282102-1Co-FjuJ6QMNSP5RWtPdGC8G